16

On sublime text I'm getting following error while trying to validate JS.

[Errno 2] No such file or directory: 'node'
[cmd: ['node', '/Users/gurpreetsingh/Library/Application Support/Sublime Text 3/Packages/JSLint/linter.js', '--sloppy', '--indent', '2', '--node', '--nomen', '--vars', '--plusplus', '--stupid', '--todo', '/Users/gurpreetsingh/Documents/dev/aimia/infrastructure/endeavour-callcentre/endeavour-callcentre-web/src/main/webapp/js/modules/membervalidation.js']]
[dir: /Users/gurpreetsingh/Documents/dev/aimia/infrastructure/endeavour-callcentre/endeavour-callcentre-web/src/main/webapp/js/modules]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]


//Additional Information 
Node version :v0.10.13
which node: /usr/local/bin/node
echo $PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
RuntimeException
  • 1,135
  • 2
  • 11
  • 25

5 Answers5

19

Sublime can't find node, because as its path listing shows, it's not looking in /usr/local/bin. You need to modify the settings to point to /usr/local/bin/node, not just node, and you'll be all set.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
13

I was able to get node working by downloading and installing node at (nodejs.org), then modifying the Sublime Text 2 build system using this:

{
    "cmd": ["/usr/local/bin/node", "$file", "$file_base_name"],
    "working_dir": "${project_path:${folder}}",
    "selector": "*.js"
}
Will
  • 11,276
  • 9
  • 68
  • 76
4

Go to:

Preferences > Package Settings > JSLint > Advanced Build Settings

Then set the node path as you have it installed. If you don't know, just type "which node" in the terminal to find out the correct path.

pat
  • 5,757
  • 5
  • 25
  • 30
  • no such navigation on JSlint in Key bindingd and user settings (User and default)are there. how to do in sublime text3 – xkeshav Dec 01 '14 at 10:30
3

You need to tell JSLint package where your node is. Take Sublime Text 2 on Mac OS X for example, you need to open file /Users/shawnzhu/Library/Application Support/Sublime Text 2/Packages/JSLint/JSLint.sublime-build and update the first element of the array value of the key cmd like this:

"/usr/local/bin/node"

Then save this file and re-run your Sublime text

shawnzhu
  • 7,233
  • 4
  • 35
  • 51
1

Just for reference, If you are using Sublime Text 2, there are multiple ways to fix this problem:

  1. You can see the last paragraph in the official documentation.
  2. You can manually hack it by following these instructions (if the first method didn't work):

    vim ~/Library/Application Support/Sublime Text 2/Packages/JSLint/JSLint.py
    

    then in line 16 you can see the path variable like this:

    if os.name == "posix":
        path = "/usr/local/bin:" + os.environ['PATH']
    else:
    

    prepend your path to the first string. e.g. if you are using macports to install your node:

    path = "/opt/local/bin:/usr/local/bin:" + os.environ['PATH']
    

Don't forget to remove

rm ~/Library/Application Support/Sublime Text 2/Packages/JSLint/JSLint.pyc

that is in the same directory.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Anastasios Andronidis
  • 6,310
  • 4
  • 30
  • 53