I am debugging a node application in Visual Studio, so I have to attach create a new configuration in launch.json:
{
"type": "node",
"request": "attach",
"name": "Debug API",
"remoteRoot": "/workspaces/telehealth/projects/api",
"localRoot": "${workspaceFolder}/projects/api",
"protocol": "inspector",
"port": 9229,
"restart": true,
"address": "localhost",
"skipFiles": ["<node_internals>/**"]
}
And the script in package.json is
nodemon -e js,gql --watch dist --watch typeDefs --delay 500ms --inspect=0.0.0.0:9229 ./dist/index.js
That works fine the first time, but when I save a file and the server restarts, it fails with the classical error address already in use because the debugger is running. I have to turn off the debugger, wait 5 seconds and then save the file to restart the server. After that, I have to start the debugger again.
There should be a way to restart without stopping the running process to debug, but I couldn't find nothing