Node: Debugger isn't stopped at the `debugger;` statement when debugging using `--inspect`

Created on 26 Dec 2016  路  7Comments  路  Source: nodejs/node

v6.9.2:
Windows10 x64:

When debugging with Chrome using $ node --inspect filename feature described here, the debugger isn't stopped at the debugger; statement as stated in the same manual

Inserting the statement debugger; into the source code of a script will enable a breakpoint at that position in the code:

for the $ node debug filename feature.

Is behavior different for the --inspect feature and debugger; statement is not supported?

inspector question

Most helpful comment

debugger; statements are supported by node --inspect. However, they are ignored until the debugger is connected. You probably have to use the --debug-brk flag as well to pause the application at the start and have the time to open the developer tools.

All 7 comments

debugger; statements are supported by node --inspect. However, they are ignored until the debugger is connected. You probably have to use the --debug-brk flag as well to pause the application at the start and have the time to open the developer tools.

Got it, thanks! So in this case $ node debug myscript.js the debugger is connected immediately so that I don't need to pass --debug-brk, correct?

$ node debug is not using the inspector protocol.

@eugeneo, so is my understanding correct that if --inspect is used, the debugger; statements are ignored until the debugger is connected. However, if $ node debug is used, the inspector protocol is not used, and debugger is stopped at the debugger; statements even before the debugger is connected?

@maximusk That's correct. If you want to match node debug behaviour, use node --inspect --debug-brk as @targos mentioned.

Update on this. The flag has changed recently to --inspect-brk. So:

node --inspect-brk

Hi max i had the same issue. I tried "node inspect app.js" to start the debugger using the inspector protocol without the two dashes "--" and it worked. I used the chrome devtools with chrome://inpsect

Reference: https://nodejs.org/api/debugger.html -- node -v v12.19.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dfahlander picture dfahlander  路  3Comments

mcollina picture mcollina  路  3Comments

Brekmister picture Brekmister  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

srl295 picture srl295  路  3Comments