I am trying to use the debugger in Visual Studio Code on a macOS Catalina for a node app. I created a very simple example to illustrate my case.
index.js
require('http').createServer( (request, response) => {
  response.writeHead(200, {'Content-Type': 'text/plain'})
  response.end('Hello World\n');
  response.end();
}).listen(3000);
Dockerfile
FROM node:12.14.0-alpine 
COPY . /src
CMD ["node","--inspect=0.0.0.0", "src/index.js"]
I build the Dockerfile
docker build . -t debugtest
and then run it
 docker run -p 3000:3000 -p 9229:9229 debugtest
I can access http://localhost:3000/.
I set a breakpoint in index.js.
Then setup a debugger target in visual studio code
{
  "version": "0.2.0",
  "configurations": [
  {
    "type": "node",
    "request": "attach",
    "name": "Attach",
    "port": 9229,
    "skipFiles": [
      "<node_internals>/**"
    ]
  }
  ]
}
Now when I start the debugger in visual code the red dot of the breakpoint disappears and "Breakpoint set but not yet bound" appears.

I have seen that question in various spots but none of the solutions worked. When I run the node process outside of docker node --inspect index.js it works without a hitch.
I am using version 1.41.1 of visual studio code and docker 2.1.0.5.
Turns out I was omitting the remoteRoot attribute in launch.json. The below works.
launch.json
{
  "version": "0.2.0",
  "configurations": [
  {
    "type": "node",
    "request": "attach",
    "name": "Attach",        
    "port": 9229,
    "remoteRoot": "/src/",
    "skipFiles": [
      "<node_internals>/**"
    ]
  }
  ]
}
                        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