Visual Studio Code - Node debugger breakpoints not being hit

Try this configuration in your launch file:

{
    "name": "Attach to Process",
    "type": "node",
    "protocol": "inspector",
    "request": "attach",
    "stopOnEntry": false,
    "port": 5858,
    "localRoot": "${workspaceRoot}",
    "remoteRoot": "/somepath/myprojectroot",
    "sourceMaps": true
}

Make sure the remoteRoot is correct path, otherwise it won't know where to look for the source files.


On the VSCode settings search for 'debug javascript use preview', and then disable it. It should now bound all breakpoints.



I had a similar problem, I fixed it by appending /src to the "webRoot" path.


Here is an Example to Demonstrate What I Did:

Originally my "webRoot" property read:

 "webRoot": "${workspaceFolder}"

Now my webRoot path reads:

"webRoot": "${workspaceFolder}/src",


Here is my ./.vscode/launch.json reads:


    {
      // 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": [
        {
          "type": "chrome",
          "request": "launch",
          "name": "Launch Chrome",
          "url": "http://localhost:3000",
          "webRoot": "${workspaceFolder}/src",
          "trace": true
        }
      ]
    }

I had this issue with VSCode 1.52.1, the fix that worked for me was:

  1. Disable debug.javascript.usePreview via Code > Preferences > Settings

  2. Add "localRoot": "${workspaceFolder}/" to launch.json

  3. Add "remoteRoot": "${workspaceFolder}/" to launch.json