11

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.

3
  • Appreciate its not quite the same issue. I had a problem unbound breakpoints in Angular using VSCode. There is some information that may be useful in this github issue. Note, you can collect a debug trace from VSCode following the suggestions in this comment (part of the same github issue)
    – 0909EM
    Oct 7, 2020 at 22:40
  • Posted the issue in vscode's github, It has a fix now on the nightly build. github.com/microsoft/vscode/issues/108418
    – ShocKwav3_
    Oct 17, 2020 at 10:37
  • 1
    I feel your pain, setting up launch configs in VSCode is a black art, and it takes me hours or even days every time I need to do it. The Node.js website says all you need to do is create a new project and press F5, but this is total bull****
    – bikeman868
    May 16 at 3:50

2 Answers 2

4

I had a similar problem with unbound breakpoints. My issue was an incorrect field in my launch.json:

"localRoot": "${workspaceFolder}/server",

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.

0

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 the app.ts. In the other files, the breakpoints were set to "unbound" Here is my launch.json

    {

    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${file}",
            "sourceMaps": true,
            "preLaunchTask": "tsc: build - tsconfig.json",
            "outFiles": [
                "${workspaceFolder}/dist/**/*.js"
            ]
        }
    ]
}
1
  • Thanks for posting your launch config. When I tested this, I got different behaviors depending on how I set my default profile for the terminal window. Which profile are you using?
    – bikeman868
    May 16 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.