I have a NodeJs project and I run it using nodemon,
I wish to run it in debug mode for development tasks, but I am unable to do so.
I found that I\'ll need to ad
I ran into a similar issue attaching to a Dockerized nodemon process. I found the solution in this article. I was able to get it working by changing three things:
--inspect=0.0.0.0 to the npm script that launched the service (named debug in my case): "scripts": {
"debug": "nodemon -w lib -w server.js --inspect=0.0.0.0 server.js"
}
docker-compose, so it's defined in the associated yaml:ports:
- "8080:8080"
- "9229:9229"
launch.json in VS Code: "configurations": [
{
"name": "Attach to Node in Docker",
"type": "node",
"address": "localhost",
"port": 9229,
"request": "attach",
"restart": true
}
]
The "restart": true option allows the debugger to automatically reattach when nodemon recompiles things after a watched file changes.