Ñhosko
Ñhosko

Reputation: 795

VSCode NodeJs: Debugger not stopping at breakpoint (WSL2/Ubuntu18)

Using WSL2/Ubuntu18 I've not been able to make the VSCode NodeJs Debugger to stop on the breakpoints of any NodeJs app. When I start the debugger, it runs (I can see the output on the integrated terminal) but breakpoints are simply ignored.

The simple.js file, with a breakpoint on line 3:

Simple JS with Breakpoint at line 3

The launch.json is set to:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "NodeJs: Launch Program",
            "program": "${file}",
            "request": "launch",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "pwa-node",
            "console": "integratedTerminal"
        }
    ]
}

When I press F5 or click on the "Start Debugging" button on VS Code, the app runs and following appears on the integrated Terminal:

/usr/bin/env 'NODE_OPTIONS=--require /home/myuser/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/extensions/ms-vscode.js-debug/src/bootloader.bundle.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.19338-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/myuser/.nvm/versions/node/v14.15.1/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-ff32d873905abafa"}' /home/myuser/.nvm/versions/node/v14.15.1/bin/node ./simple.js 
Debugger attached.
0
1
2
3
4
Waiting for the debugger to disconnect...

I've already upgraded from Node10 to Node14, but the problem persists.

On another computer using WSL1, and using the same launch.json the debugger stops at the given breakpoints. Do I need to set something additionally on WSL2? For the record, this is what appears on the integrated terminal on the WSL1 computer before it stops at line 3:

/usr/bin/env 'NODE_OPTIONS=--require /home/myuser/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/extensions/ms-vscode.js-debug/src/bootloader.bundle.js --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.787-3.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/myuser/.nvm/versions/node/v14.15.1/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/tmp/node-debug-callback-b901b6d6e3e9799b"}' /home/myuser/.nvm/versions/node/v14.15.1/bin/node ./simple.js 
Debugger attached.
<Breakpoint hit and stop...>

Debugger stops at breakpoint

Additional info, debugging Python3 files work correctly on both machines.

Both computers have the same VS Code Version installed.

Update:

You can follow the issue on GitHub: https://github.com/microsoft/vscode/issues/113283

Upvotes: 3

Views: 4795

Answers (2)

Govind Kumar
Govind Kumar

Reputation: 1

For me in visual studio code in javascript debug terminal I was having this issue

--inspect-publish-uid= is not allowed in NODE_OPTIONS

I moved the visual studio code to the Application folder and it worked out. Earlier it was inside Downloads folder.

Upvotes: 0

&#209;hosko
&#209;hosko

Reputation: 795

The problem is that the NodeJs App is being run from a symlinked address - so the debugger can not handle it.

Answer from one of the developers of VSCode/NodeJS on github:

It looks like you have your script symlinked into /bin/nhosko/simple.js, but its actual location is /mnt/c/Users//bin-nhosko/simple.js. In this case you need to specify some flags so that Node will report the linked location that vscode sees and told the debugger about: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_can-i-debug-if-im-using-symlinks. I want to make the debugger smart enough to fix this automatically in microsoft/vscode-js-debug#776.

https://github.com/microsoft/vscode/issues/113283#issuecomment-750371948

Upvotes: 1

Related Questions