如题
1)集成Nodejs插件到sublime,地址:https://github.com/tanepiper/SublimeText-Nodejs
2)解压zip文件, 并重命名文件夹“Nodejs”
3)打开sublime的插件文件夹,操作"preference(首选项)" --> "Browse packages(浏览插件)",或者sublime安装目录下的Data\Packages
4)“Nodejs”复制到插件文件夹
5)打开Nodejs文件夹,更改配置文件。打开文件“Nodejs.sublime-build”
- {
- "cmd": ["node", "$file"],
- "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
- "selector": "source.js",
- "shell":true,
- "encoding": "cp1252",
- "windows":
- {
- "cmd": ["taskkill /F /IM node.exe & node", "$file"]
- },
- "linux":
- {
- "cmd": ["killall node; node", "$file"]
- }
- }
把cp1252修改为GB2312或者utf8,防止build nodejs代码时终端显示乱码 ,修改如下
- {
- "cmd": ["node", "$file"],
- "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
- "selector": "source.js",
- "shell":true,
- "encoding": "utf8",
- "windows":
- {
- "cmd": ["taskkill /F /IM node.exe & node", "$file"]
- },
- "linux":
- {
- "cmd": ["killall node; node", "$file"]
- }
- }
6)再打开文件“Nodejs.sublime-settings”,或者设置“preference(首选项)”-->“package settings(插件设置)”-->Nodejs”-->“setting-default”
- {
- // 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,
- // as 'NODE_PATH' environment variable for node runtime
- "node_path": false,
-
- "expert_mode": false,
-
- "ouput_to_new_tab": false
- }
修改如下
- {
- // 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/bin/nodejs,
- // Same for NPM command
- "npm_command": /usr/bin/npm,
- // as 'NODE_PATH' environment variable for node runtime
- "node_path": false,
-
- "expert_mode": false,
-
- "ouput_to_new_tab": false
- }