Mac 下安裝sublime text3 Nodejs
阿新 • • 發佈:2019-02-13
暈死居然花了一個多小時~下來來個詳細版本的。。
/bin/sh: node: command not found
如果遇到這個問題,這篇教程簡直就是為你量身定做!!!
首先你得有nodejs在電腦裡,沒有的話就去nodejs.org下載
1.去github下載nodejs:
https://github.com/tanepiper/SublimeText-Nodejs
2.解壓,改名為Nodejs 此處注意大小寫
3.SublimteText3 --> Preferences--> Browse Packages 把解壓好的檔案放進去
4.開啟bash shell, 輸入指令
和which node
which npm
得到絕對路徑,
比如我的就是
/usr/local/bin/node 和 /usr/local/bin/npm
5.開啟Nodejs(剛才解壓並且放好的那個檔案),找到 Nodejs.sublime-settings,用sublime開啟,如下
{ // 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 }
把false改為自己的路徑, false --> "/usr/local/bin/node"
6.開啟Nodejs(剛才解壓並且放好的那個檔案),開啟Nodejs.sublime-build,改為如下:
7. 開啟一個新的檔案,敲進console.log('hello world') 然後control+r就運行了{ "cmd": ["node", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.js", "shell":true, "encoding": "utf-8", "windows": { "cmd": ["taskkill /F /IM node.exe & node", "$file"] }, "linux": { "cmd": ["killall node; node", "$file"] }, "osx": { "cmd": ["/usr/local/bin/node; node $file"] } }