node.js Sublime [Errno 2] 没有这样的文件或目录:'node'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18014360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sublime [Errno 2] No such file or directory: 'node'
提问by RuntimeException
On sublime text I'm getting following error while trying to validate JS.
在 sublime text 上,我在尝试验证 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
回答by MattDMo
Sublime can't find node, because as its pathlisting 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.
Sublime 找不到节点,因为正如它的path列表所示,它没有在/usr/local/bin. 您需要将设置修改为指向/usr/local/bin/node,而不仅仅是node,您将全部设置完毕。
回答by Will
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:
我能够通过在(nodejs.org)下载和安装节点来让节点工作,然后使用这个修改 Sublime Text 2 构建系统:
{
"cmd": ["/usr/local/bin/node", "$file", "$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector": "*.js"
}
回答by stormpat
Go to:
去:
Preferences > Package Settings > JSLint > Advanced Build Settings
首选项 > 包设置 > JSLint > 高级构建设置
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.
然后在安装时设置节点路径。如果您不知道,只需在终端中输入“哪个节点”即可找出正确的路径。
回答by shawmzhu
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-buildand update the first element of the array value of the key cmdlike this:
你需要告诉 JSLint 包你的节点在哪里。以 Mac OS X 上的 Sublime Text 2 为例,你需要像这样打开文件/Users/shawnzhu/Library/Application Support/Sublime Text 2/Packages/JSLint/JSLint.sublime-build并更新键的数组值的第一个元素cmd:
"/usr/local/bin/node"
Then save this file and re-run your Sublime text
然后保存这个文件并重新运行你的 Sublime 文本
回答by Anastasios Andronidis
Just for reference, If you are using Sublime Text 2, there are multiple ways to fix this problem:
仅供参考,如果您使用的是 Sublime Text 2,有多种方法可以解决此问题:
- You can see the last paragraph in the official documentation.
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.pythen in line 16 you can see the
pathvariable 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
macportsto install your node:path = "/opt/local/bin:/usr/local/bin:" + os.environ['PATH']
- 您可以在官方文档中看到最后一段。
您可以按照以下说明手动破解它(如果第一种方法不起作用):
vim ~/Library/Application Support/Sublime Text 2/Packages/JSLint/JSLint.py然后在第 16 行你可以看到这样的
path变量:if os.name == "posix": path = "/usr/local/bin:" + os.environ['PATH'] else:将您的路径添加到第一个字符串。例如,如果您
macports用于安装节点: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.
即在同一目录中。

