Node Mac 環(huán)境搭建

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代碼了。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容