晕死居然花了一个多小时~下来来个详细版本的。。
/bin/sh: node: command not found
如果遇到这个问题,这篇教程简直就是为你量身定做!!!
首先你得有nodejs在电脑里,没有的话就去nodejs.org下载
1.去github下载nodejs:
https://github.com/tanepiper/SublimeText-Nodejs
2.解压,改名为Nodejs 此处注意大小写
3.SublimteText3 --> Preferences--> Browse Packages 把解压好的文件放进去
4.打开bash shell, 输入指令
which node
和
which npm
得到绝对路径,
比如我的就是
/usr/local/bin/node 和 /usr/local/bin/npm
5.打开Nodejs(刚才解压并且放好的那个文件),找到 Nodejs.sublime-settings,用sublime打开,如下
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "/usr/local/bin/node",
// Same for NPM command
"npm_command": "/usr/local/bin/npm",
// as 'NODE_PATH' environment variable for node runtime
"node_path": false,
"expert_mode": false,
"ouput_to_new_tab": false
}
把false改为自己的路径, false --> "/usr/local/bin/node"
6.打开Nodejs(刚才解压并且放好的那个文件),打开Nodejs.sublime-build,改为如下:
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "utf-8",
"windows":
{
"cmd": ["taskkill /F /IM node.exe & node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
},
"osx":
{
"cmd": ["/usr/local/bin/node; node $file"]
}
}
7. 打开一个新的文件,敲进console.log('hello world') 然后control+r就运行了