Minimal reproducible repo:
https://github.com/ShocKwav3/babel-node-basic
I am trying to setup debugger with vscode for a nodejs app. I am running the app with babel-node
. No matter what I try, the breakpoint shows unbound.
I am running the app with this command
nodemon --exec './node_modules/.bin/babel-node --inspect=0.0.0.0 src/bin/www'
Dockerfile:
FROM node:12
WORKDIR /usr/src/app/home_automation_server
COPY package*.json ./
RUN yarn install
COPY . .
Compose config:
server:
image: home_automation_server
volumes:
- .:/usr/src/app/home_automation_server
working_dir: /usr/src/app/home_automation_server
ports:
- 3000:3000
- 9229:9229
depends_on:
- db
- redis
networks:
- servernet
env_file:
- ./server.env
- ./database.env
command: ["sh", "entrypoint.sh", "run"]
tty: true
.babelrc:
{
"presets": [
[
"@babel/preset-env",{
"targets": {
"node": "current"
}
}
]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
["module-resolver", {
"root": ["./"],
"alias": {
"projectRoot": "./",
"src": "./src"
}
}]
],
"sourceMaps": "inline"
}
launch.json:
{
"type": "node",
"request": "attach",
"name": "Debug: HA dev server",
"port": 9229,
"restart": true,
"trace": true,
"address": "localhost",
"localRoot": "${workspaceFolder}/src/bin",
"remoteRoot": "/usr/src/app/home_automation_server/src/bin",
"protocol": "inspector",
"sourceMaps": true
}
When I connect the debugger it connects
If I use inspect-brk
the app stops at first line and when debugger connects I can step through.
But when I set a breakpoint it does not work and grays out. Says "Unbound breakpoint"
What am I doing wrong? I have been at this for a long time and tried almost everything I could find by searching through google.
2
Answers
I had a similar issue, the problem was with launch.json, I had in the property
"program": "app.ts"
, I changed to"program": "$ {file}"**
. I could only test theapp.ts
. In the other files, the breakpoints were set to "unbound"Here is my launch.json
I had a similar problem with unbound breakpoints. My issue was an incorrect field in my launch.json:
I had forgot to include the /server. My launch.json file was back one directory relative to the nodejs app I was trying to debug in my directory labelled /server.