Sublime Text3配置node.js環境
阿新 • • 發佈:2019-01-24
安裝
2.解壓下載的檔案後把SublimeText-Nodejs-master資料夾重新命名為Nodejs
3.開啟Sublime Text3,點選Perferences > Browse Packages開啟“Packages”資料夾,並將Nodejs資料夾剪下進來
4.開啟Nodejs資料夾下的Nodejs.sublime-build檔案,
將 “encoding”: “cp1252” 改為 “encoding”: “utf8” ,儲存檔案
{
"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"
}
}
5.開啟Nodejs資料夾下的Nodejs.sublime-settings檔案,
將 “node_command”:false改為 “node_command”: “C:\\Program Files\\nodejs\\node.exe” ,
將 “npm_command”: false 改為 “npm_command”: “C:\\Program Files\\nodejs\\node.exe” ,儲存檔案
{
"save_first": true,
"node_command": "C:\\Program Files\\nodejs\\node.exe" ,
"npm_command": "C:\\Program Files\\nodejs\\node.exe",
"node_path": false,
"expert_mode": false,
"output_to_new_tab": false
}
6.建立測試檔案test.js
console.log('hello world');
7.按“ctrl+B”執行程式碼,執行結果如下圖所示