Skip to content

Cannot attach debugger to a node.js application running inside a Docker container #59

@m90

Description

@m90

I'm trying to attach the Visual Studio Code debugger to a node.js app that is running inside a Docker container.

The app starts like:

node --debug-brk app.js

My docker-compose.yml exposes the port for attaching:

app:
  build: .
  working_dir: /code
  volumes:
    - .:/code
  command: npm run debug
  ports:
    - "3004:3000"
    - "5858:5858"

launch.json is pretty simple:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Docker",
            "type": "node",
            "request": "attach",
            "port": 5858
        }
    ]
}

Now, when I start the application and attach the debugger this will correctly connect (I can see the values flashing in the debugger UI already), but then it will stop, telling me the following:

Error opening 'app.js' (File not found: /code/app.js).

Is there any way to fix this path offset? Should one handle this scenario completely different?

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions