vscode nodemon debug 配置
vscode是比較不錯的JS開發工具。nodemon可以實現修改JS程式碼後的自動重啟server,不需要手動在去重啟server。
1,安裝nodemon
# npm install -g nodemon
2,建立測試專案
# express --view=ejs mytest # cd mytest # npm install
3,修改package.json
"scripts": { "start": "node ./bin/www", "debug": "nodemon --inspect ./bin/www" },
4,修改.vscode/launch.json
{ // 使用 IntelliSense 瞭解相關屬性。 // 懸停以檢視現有屬性的描述。 // 欲瞭解更多資訊,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Node: Nodemon", "processId": "${command:PickProcess}", "restart": true, "protocol": "inspector", } ] }
5,以debug模組啟動專案,可以通過vscode自帶的終端來啟動
# npm run debug
6,在routes/index.js打斷點
7,瀏覽器訪問網站,vscode的終端,除錯控制檯就有斷點的內容了

vscode debug