一、版本
sublime text3
![](https://img.haomeiwen.com/i10009118/cbb62d8e871b122f.png)
node
![](https://img.haomeiwen.com/i10009118/b6ffacc403d0ab7f.png)
二、其他教程好多坑
其实sublime 的nodejs是完全可以按照插件进行安装的,其他教程非要下载包然后配置,还有配置文件内容也不好使
三、我的安装
打开sublime ,按键cmd+shif+p,安装插件
![](https://img.haomeiwen.com/i10009118/f1c7d08fabd7add9.png)
搜索nodejs
然后选择安装,当安装好后,找到安装目录
![](https://img.haomeiwen.com/i10009118/3f805f50a3612a40.png)
找到下面两个文件
![](https://img.haomeiwen.com/i10009118/99a2501fddf8ab18.png)
*****build内容
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": true,
"encoding": "cp1252",
"windows":
{
"shell_cmd": "taskkill /F /IM node.exe & node $file"
},
"linux":
{
"shell_cmd": "killall node; /usr/bin/env node $file"
},
"osx":
{
//"shell_cmd": "killall node; /usr/bin/env node $file"
"cmd": "/usr/local/bin/node; node $file"
}
}
***settings内容如下
{
// 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": false,
// Same for NPM command
//"npm_command": false,
"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,
"output_to_new_tab": false
}
测试安装成功
control+r快捷键
![](https://img.haomeiwen.com/i10009118/6ab05120dd285de0.png)
注意:
如果安装nodejs报错,找不到什么模块的话,cnpm install 模块名
安装即可。然后remove插件重新安装。
网友评论