piuccio / sublime-esformatter

JavaScript formatter plugin for Sublime Text
MIT License
28 stars 20 forks source link

Error: Please make sure that node.js is installed and in your PATH #17

Closed ghost closed 10 years ago

ghost commented 10 years ago

When i hit cmd + alt + f i get this error dialog:

It looks like node is not installed. Please make sure that node.js is installed and in your PATH

I have node installed at /usr/local/bin/node, and can access in terminal just fine.

piuccio commented 10 years ago

Which operating system and sublime version?

ghost commented 10 years ago

OSX 10.9, Sublime 3059, Node.js v0.10.21

glukki commented 10 years ago

The same with me. OSX 10.9, Sublime 3059, node v0.10.26. Node installed by brew, and accessible via symlink /usr/local/bin/node. /usr/local/bin is in PATH

Ok, I typed import os; print(os.environ.get('PATH')); in Sublime console, and now I see, that app environment is different from bash environment. My Sublime has only /usr/bin:/bin:/usr/sbin:/sbin =\

Finally, this line works fine, but I'm not sure if this is a bad hack :) Also, I'm not familiar with Sublime API and how is it meant to run external programs with a plugin. from subprocess import check_output; check_output([ os.environ.get('SHELL'), '-l', '-c', 'node -v' ]);

mauricesvay commented 10 years ago

Same problem here

justinb26 commented 10 years ago

I finally got fed up with this one and tracked it down. You can fix it by editing "~/Library/Application Support/Sublime Text 2/Packages/esFormatter/Default (OSX).sublime-keymap" and adding "+shift" to the key binding, or changing/removing it entirely.

I haven't done this particular operation before, but my understanding is that you should be able to edit the corresponding file under ~/Library/Application Support/Sublime Text 2/Packages/User. This didn't work for me, but I could be missing something; or, the library could be loading preferences in an odd way - I noticed it doesn't expose keybindings in the preference dropdown, which would have been helpful in this case :)

leobalter commented 10 years ago

@justinb26, I tried to change the keymap as suggested but it just doesn't fix anything. I still get the message about the wrong path.

glukki commented 10 years ago

Keymap has absolutely no business with this problem. Source of this problem on OSX is in PATH environment variable.

leobalter commented 10 years ago

Ok, I'm really not a Python developer and I was able to include '/usr/local/bin:/usr/local/sbin' to the PATH with this tweak below. I just don't know if it's good or silly. I'll push a PR quoting Python friends.

# Tweak line below as needed for your $PATH
LOCAL = '/usr/local/bin:/usr/local/sbin'

# Sublime's default path is
# /usr/bin:/bin:/usr/sbin:/sbin
# it'll be prepended to your custom one
os.environ['PATH'] += ':'
os.environ['PATH'] += LOCAL