node 官網(wǎng)下載mac版本node按步驟安裝
安裝subline text3
1.為sublime text下載nodejs插件(下載地址:2.https://github.com/tanepiper/SublimeText-Nodejs)
3.解壓下載的zip文件并將文件夾命名為Nodejs
4.復(fù)制Nodejs文件夾到sublime的Preferences-Package文件夾中
5.修改Nodejs.sublime-build和Nodejs.sublime-settings
6.修改后的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:\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
}
7.修改后的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"]
},
"osx":
{
"cmd": ["/usr/local/bin/node; node $file"]
}
}
再重啟sublime,選中Tool-build System-Nodejs
編輯Nodejs文件,并保存為后綴為js的文件(如果不保存為.js文件,sublime是無法顯示運(yùn)行結(jié)果的)這樣我們就可以通過Tool-Nodejs-Run來運(yùn)行Nodejs代碼了。