Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - Node debugger breakpoints not being hit

I am trying to use VSCode to debug a node app I am running.

I launch the app in a separate terminal and then use the attach to process configuration to hook into it.

The attaching works correctly and I get a side panel that says 'loaded scripts' with the files in my project. If I click on one of those and set breakpoints there it will work correctly.

If I set a breakpoint on a file I open through the VSCode editor the breakpoint is greyed out and when I hover over it will say 'Breakpoint set but not yet bound'.

How can I make it so that the breakpoints I set on the code are bound?

like image 816
nazbot Avatar asked Oct 19 '17 01:10

nazbot


People also ask

Why breakpoint is not hitting with VS Code?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do you hit breakpoints in Visual Studio Code?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.

How do I Debug node js code VS Code?

There are a few ways you can debug your Node. js programs in VS Code: Use auto attach to debug processes you run in VS Code's integrated terminal. Use the JavaScript debug terminal, similar to using the integrated terminal.


2 Answers

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.

like image 52
Alkasai Avatar answered Sep 17 '22 14:09

Alkasai


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

like image 28
LEMUEL ADANE Avatar answered Sep 16 '22 14:09

LEMUEL ADANE