Sublime 与 Node.js 的配置
搞半天,终于配好了
小结一下:
1. 先去下载sublime的node插件 https://github.com/tanepiper/SublimeText-Nodejs 右下角的download zip按钮
2. 解压缩,然后在sublime3的preference菜单,点击browse pckages ,打开文件夹,然后把解压缩出来的文件夹放在这里,改名nodejs
3. 文件夹内打开nodejs.sublime-build 文件,按如下方式改:
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "cp936",
"working_dir":"${project_path:${folder}}",
"windows":
{
"cmd": ["taskkill","/F","/IM","node.exe","&","taskkill","/F","/IM","redis-server.exe","&","build.bat"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
}
}
两个关键点:
1. encoding:默认是cp1285什么的,得改成cp936,否则乱码
2. windows:cmd:后面的部分,得这样写。我这里加了redis,build.bat里面有启动redis的命令
然后就可以tool->build system->nodejs,然后ctl-build来运行了。