How to debug a nodemon project in VSCode

故事扮演 提交于 2019-12-05 20:02:25

Change package.json to

"scripts": {
    "dev": "node app.js",
    "debug": "nodemon --inspect app.js"
}

--inspect is for versions >= 6.3. --legacy or --auto for older versions

And launch.json to:

"version": "0.2.0",
"configurations": [
    {
        "type": "node",
        "request": "attach",
        "name": "Node: Nodemon",
        "processId": "${command:PickProcess}",
        "restart": true,
        "protocol": "inspector"
    }
]

the restart flag is the key here.

Start app via new debug script

npm run debug

  • In Debug view, select the Node: Nodemon configuration and press play or F5
  • Choose the process started above

See more: vscode nodemon recipe

nodemon listens to files changes and re-start the app on another process

So your configuration is correct but the debugger never "sees" the breakpoints .

There is no point of running debug mode with nodemon .

That's is a feature you may want to request on VScode(Auto-Restart on code change)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!