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?
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
Most helpful comment
debugger;
statements are supported bynode --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.