I'm trying to debug my node + babel project with VScode without success. I read a lot of answers no one fixed my problem. How should launch.json look alike?
I want to be able to attach the debugger to a running process and launch the program.
Package.json
"build-babel": "npx babel src -d dist",
"start": "node dist/server.js",
"dev-start": "nodemon --inspect-brk --exec babel-node ./src/server.js",
First try from: Can Visual Studio Code be configured to launch with nodemon
launch.json
{
"type": "node",
"request": "launch",
"name": "Nodemon",
"runtimeExecutable": "${workspaceRoot}/node_modules/nodemon/bin/nodemon.js",
"args": [
"${workspaceRoot}/src/server.js"
],
"restart": true,
"protocol": "inspector",
"stopOnEntry": true,
},
{
"type": "node",
"request": "attach",
"name": "Attach to app",
"port": 9229,
"address": "localhost",
"sourceMaps": true,
"smartStep": true,
"restart": true
},
update
I also tried this:
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"program": "${workspaceFolder}/src/server.js",
"restart": true,
"console": "integratedTerminal",
"port": 9229,
"args": ["--exec", "babel-node", "--babel-preset-es2015"],
"internalConsoleOptions": "neverOpen"
}
run it when there is a server process running from a terminal: attached but the breakpoints don't got hit "set but not yet bound"
The launch process result error: Cannot connect to runtime process- reason: connot connect to the target: connect econnrefused 127.0.0.1:9229
Thank you