Visual Studio 2019 node.js docker remote debug: breakpoint set but not yet bound

Viewed 311

I'm trying to attach remote debugger of Visual Studio 2019 to node.js app in docker container. What I do:

  1. I have created example node.js/express project in Visual Studio using "Basic Node.js Express 4 Application" template.
  2. I have created docker image with following dockerfile:
FROM node:alpine
ADD ./TestApp/ExpressTestApp/ /
ENTRYPOINT node --inspect="0.0.0.0" /app.js
  1. I launch container with following command:
docker run -p 3000:3000 -p 9229:9229 test
  1. The app works, pages open on address http://localhost:3000/, console output states that debugger is active:
Debugger listening on ws://0.0.0.0:9229/73b5b00d-a492-4842-81e5-d50c12e64ac9
For help, see: https://nodejs.org/en/docs/inspector
  1. In Visual Studio 2019, I click "Debug -> Attach to process...". In opened dialog I choose "Chrome devtools protocol websocket (no authentication)", enter ws://localhost:9229/73b5b00d-a492-4842-81e5-d50c12e64ac9 as a connection target and I can see and connect to node.js debugger in docker:

Attach to Process dialog

  1. I can successfully attach to the process (node.js output states "Debugger attached."). But I can't use breakpoints in source files. When I place brakepoint, it shows the message "The breakpoint will not currently be hit. Breakpoint set but not yet bound."

How to make it work in Visual Studio?

I've tried to debug my app in VS Code, using following launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to remote",
            "protocol": "inspector",
            "port": 9229,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/"
        }
    ]
}

And it works perfectly. Breakpoints, variables values watching and etc. And I don't need to specify generated GUID of debugger, which is great too.

How to achieve the same thing in Visual Studio 2019?

0 Answers
Related