Debugging-Nodejs-With-VSCode
環境
- Nodejs - 7.9.10
- VSCode - 1.12.2
Download VSCode
vscode

點擊這個 Icon 後再點擊齒輪會自動產生 launch.json
launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "protocol": "inspector", "program": "${workspaceRoot}/index.js", "cwd": "${workspaceRoot}", "runtimeArgs": [ "--nolazy", "--inspect-brk" ], "console": "integratedTerminal", "env": { "NODE_ENV": "development" } } ] }
|
- console - 在Terminal 中啟動程式
- env - 設定動態變數,可以傳入程式中使用
- runtimeArgs - 動態參數
- program - 啟動程式路徑
- protocol - npm 8 有兩種不同的protocol , 預設是 legacy
檢查launch.json

開始 debug 後上方會多一條控制 bar

使用 postman 發送 Request

因為我有 console.log 所以在 Debug Console 中會把 login 顯示出來
