1. 程式人生 > 其它 >vscode 除錯 nodejs 程式

vscode 除錯 nodejs 程式

nodejs 服務在vscode 中的除錯

1、安裝vscode

略(這不用說了吧)

2、寫一個能跑的nodejs 程式

其實看到這個,自己已經有一個能跑的nodejs 程式,不用看我的了

我這裡是我已經在執行的程式 https://github.com/adouwt/nodejsAPI

3、專案中新建 .vscode 資料夾 新建 launch.json 檔案

  
  {
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "nodemon",
            "runtimeExecutable": "nodemon",
            "program": "${workspaceFolder}/nodeServer.js  --exec babel-node",
            "restart": true,
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }
    ]
}

其中:
"program": "${workspaceFolder}/nodeServer.js --exec babel-node",
nodeServer.js --exec babel-node 可以完全copy 你自己package.json 裡面 啟動指令碼內容,我這裡是es6 等的語法 需要babel 轉換

4、點選你的小蟲蟲

5、 戳上你的小點點


程式執行到這裡的時候 就看待具體的引數了
我這裡 是看到了users 的 具體引數

結束!

上面除錯的nodejs 程式碼, https://github.com/adouwt/nodejsAPI 是nodejs + mongodb + redis 搭建的一個 後端api 的介面。

如有轉載請註明出處!

感謝瀏覽,