I'm running a node app inside a docker container can't get the VS code debugger to hit breakpoints.
The docker container exposes port 5859. Inside the container the node app is ran with this command:
nodemon -L --watch src --exec babel-node src/server.js -- --inspect=0.0.0.0:5859 --nolazy
It reports that the debugger is listening:
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /app/src/**/*
[nodemon] starting `babel-node src/server.js --inspect=0.0.0.0:5859 --nolazy`
Debugger listening on ws://0.0.0.0:5859/5939f6b6-5ade-4ce5-9694-7df5f5b8385b
For help, see: https://nodejs.org/en/docs/inspector
And when I fire up the debug profile in VS Code it appears to attach. Below is line from the logs of the running docker container.
However, no breakpoints are hit when I set them. Is this a babel-node issue? Is there any suggested path forward to get node debugging to work with babel-node
?
My VS Code debug config:
{
"type": "node",
"request": "attach",
"name": "Docker: GraphQL",
"port": 5859,
"protocol": "inspector",
"restart": true,
"remoteRoot": "/app",
"localRoot": "${workspaceFolder}"
}
I was not able to get this to work with nodemon, but modifying my .babelrc
file to include inline source maps triggered VS code to hit the breakpoints I set. My .babelrc
file looks like this:
{
"env": {
"production": {
"presets": [
["es2015", {"modules": false}],
"stage-1"
]
},
"development": {
"presets": [
["es2015"],
"stage-1"
],
"sourceMaps": "inline",
"retainLines": true
} }
}
And the corresponding script that docker calls in package.json
. Port 5859 is exposed in the docker-compose file.
"start:docker": "babel-node src/server.js --inspect=0.0.0.0:5859 --nolazy",
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