You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Debugger isn't stopped at the debugger; statement when debugging using --inspect #10457
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.
Reacted by Marco Celotti, Lukas Knuth, Helder S Ribeiro, Felix Jamestin, Roman Nikitchenko, Chris Aslanoglou, YiFanChen99, Spencer Smith, Meiko Honma and Bryan Hoang
@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?
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
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
Things work differently between node --inspect and node inspect, see docs here. Both node --inspect and node inspect will set up an inspector agent for debugging but the latter one will enable Node CLI as a inspector client. On the other hand the former one doesn't arrange a specific debugger, which could be devtools or your IDE, for you. Therefore there might be some underlyings mechanics related to inspector clients that cause the difference you mentioned, after all in your scenario, devtools isn't the first debugger that connect to your inspector agent but Node CLI is.
Activity
targos commentedon Dec 26, 2016
debugger;statements are supported bynode --inspect. However, they are ignored until the debugger is connected. You probably have to use the--debug-brkflag as well to pause the application at the start and have the time to open the developer tools.maxkoretskyi commentedon Dec 26, 2016
Got it, thanks! So in this case
$ node debug myscript.jsthe debugger is connected immediately so that I don't need to pass--debug-brk, correct?eugeneo commentedon Dec 27, 2016
$ node debugis not using the inspector protocol.maxkoretskyi commentedon Dec 27, 2016
@eugeneo, so is my understanding correct that if
--inspectis used, thedebugger;statements are ignored until the debugger is connected. However, if$ node debugis used, the inspector protocol is not used, and debugger is stopped at thedebugger;statements even before the debugger is connected?gibfahn commentedon Dec 28, 2016
@MaximusK That's correct. If you want to match
node debugbehaviour, usenode --inspect --debug-brkas @targos mentioned.GeorgeTaveras1231 commentedon Nov 4, 2017
Update on this. The flag has changed recently to
--inspect-brk. So:crtassos commentedon Oct 26, 2020
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
HonmaMeikodesu commentedon Jul 28, 2021
Things work differently between
node --inspectandnode inspect, see docs here. Bothnode --inspectandnode inspectwill set up an inspector agent for debugging but the latter one will enable Node CLI as a inspector client. On the other hand the former one doesn't arrange a specific debugger, which could be devtools or your IDE, for you. Therefore there might be some underlyings mechanics related to inspector clients that cause the difference you mentioned, after all in your scenario, devtools isn't the first debugger that connect to your inspector agent but Node CLI is.