Question

I follow the second way shown at

http://www.wikihow.com/Create-a-Javascript-Console-in-Sublime-Text

to run nodejs file test.js in sumblime text.

test.js

console.log ("helloworld");

it reported

[Errno 2] No such file or directory
[cmd:  [u'node', u'/Users/myname/Documents/test.js']]
[dir:  /Users/myname/Documents]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

it looks like sublime can not run node correctly

Your comment welcome

Était-ce utile?

La solution

Your node executable file cannot be found by the build system, as it does not reside in any of the directories listed in path in the error message. To fix this, open Terminal and run

which node

to find out where the executable is. Copy the full path, then open the .sublime-build file you made and insert the full path to node. For example, if which node returns /usr/local/bin/node, then your .sublime-build file should look like this:

{
    "cmd": ["/usr/local/bin/node", "$file"],
    "selector": "source.js"
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top