下载node插件
https://github.com/tanepiper/SublimeText-Nodejs
下载zip压缩包后解压,文件名改为Node
打开文件“Nodejs.sublime-settings”改为如下样子
{ // save before running commands "save_first": true, // if present, use this command instead of plain "node" // e.g. "/usr/bin/node" or "C:in ode.exe" "node_command": "D:\node\node.exe",//node的地址 // Same for NPM command "npm_command": "D:\node\npm.cmd",//cmd的地址 // as 'NODE_PATH' environment variable for node runtime "node_path": false, "expert_mode": false, "output_to_new_tab": false }
打开文件“Nodejs.sublime-build”改为如下样子
{ "cmd": ["node", "$file"], "file_regex": "^[ ]*File "(...*?)", line ([0-9]*)", "selector": "source.js", "shell": true, "encoding": "utf8", "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" } }
编写一个测试文件app.js,按“ctrl+B"运行代码,运行结果如下图所示