- Add a script to start app with nodemon in inspect mode:
"server": "nodemon --inspect server.js"
- Add the following config to vscode's launch.json:
{
"name": "Attach to node",
"type": "node",
"request": "attach",
"restart": true,
"port": 9229
}
- Run app with
npm run server
. The debugger is automatically attached.
NB: Clicking the debugger's stop button doesn't end the node/nodemon process. You'd have to kill it the terminal(where you ran the script originally).