I'm running the following launch.json configuration and package.json script and it's working very well, I'm able to run the app and debug it. However, when I hit the "stop" button in the vscode debugger, nodemon is stopped but the npm process (and the entire app) keeps running. If I modify a file and save it then nodemon comes back up again (as expected). The only way to really stop the app is to hit ctrl+c in the terminal. Is there a way to stop both processes once the debugger stop button is clicked?
package.json script
"scripts": {
"start": "node app",
"debug": "nodemon --experimental-modules --inspect ./bin/www.mjs"
}
launch.json config
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229,
"restart": true,
"console": "integratedTerminal"
}
It seems that the solution is to add the --exitcrash
flag. It's working for me (at least when I initially tested it just now). So:
"scripts": {
"start": "node app",
"debug": "nodemon --experimental-modules --inspect --exitcrash ./bin/www.mjs"
}
Or alternatively:
"runtimeArgs": [
"run-script",
"debug",
"--exitcrash"
],
I got this idea from here: https://github.com/microsoft/vscode/issues/56756#issuecomment-462585020
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With