vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Not able to attach debugger for node js

Open DevHasher opened this issue 6 years ago • 6 comments

Hi, I m unable to add the debugger.. image

I get this image and my launch.json looks like this { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Docker: Attach to Node", "type": "node", "request": "attach", "port": 9229, "address": "localhost", "localRoot": "${workspaceFolder}", "remoteRoot": "/", "protocol": "inspector" } ] }

Additional info - I m using node:11-alpine and VS 1.48.1(user setup) and running the docker from docker compose using ports:

  • "3030:3030"
  • "9229:9229" command:
  • node
  • "--inspect-brk=0.0.0.0"
  • "."

and in package.json i have "scripts": { "start": "node app.js" }, none of the breakpoints are hit. please suggest

docker extension is installed. Anything else that needs to be installed?

DevHasher avatar Aug 24 '20 19:08 DevHasher

So basically i run the docker and then do f5 i do get some hit in app.js, as that the start point(eventhough no breakpoint is set)...but none of the other files are hit where actually the breakpoints are added.. and all the breakpoints also look detached

DevHasher avatar Aug 24 '20 19:08 DevHasher

Please collect a trace log using the instructions in the issue template.

connor4312 avatar Aug 24 '20 19:08 connor4312

Closing due to lack of info. Please follow up if you're able to collect trace logs.

connor4312 avatar Aug 31 '20 15:08 connor4312

@connor4312 I have mailed you the trace file. PLease check if you can get a clue as to what might be the issue that the debugger doesnt get attached!

DevHasher avatar Sep 04 '20 15:09 DevHasher

It looks like your localRoot/remoteRoot is incorrectly configured. You have, anonymized:

{
  "localRoot": "C:\Users\USERNAME\ONEDRIVE\Documents\PROJECT\LocalDev",
  "remoteRoot": "/",
}

And then set a breakpoint in c:\Users\USERNAME\ONEDRIVE\Documents\PROJECT\LocalDev\project-management-service\src\routes\user\list.js.

From the local and remote roots, we'd expect to find the file at /sentinel-management-service/src/routes/user/list.js, but it's actually at /usr/src/app/src/routes/user/list.js

connor4312 avatar Sep 04 '20 15:09 connor4312

Hi @connor4312 , thanks for the support. I m able to get the breakpoints to be hit on docker. Corrected the localRoot to point to the proper location.

DevHasher avatar Sep 07 '20 07:09 DevHasher