镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Debugger isn't stopped at the debugger; statement when debugging using --inspect #10457

Description

@maxkoretskyi

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?

Activity

  1. added
    inspectorIssues and PRs related to the V8 inspector protocol.
    questionIssues asking questions about Node.js.
    on Dec 26, 2016
  2. targos commented on Dec 26, 2016

    @targos
    Member

    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.

  3. maxkoretskyi commented on Dec 26, 2016

    @maxkoretskyi
    Author

    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?

  4. eugeneo commented on Dec 27, 2016

    @eugeneo
    Contributor

    $ node debug is not using the inspector protocol.

  5. maxkoretskyi commented on Dec 27, 2016

    @maxkoretskyi
    Author

    @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?

  6. gibfahn commented on Dec 28, 2016

    @gibfahn
    Member

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

  7. GeorgeTaveras1231 commented on Nov 4, 2017

    @GeorgeTaveras1231

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

    node --inspect-brk
    
  8. crtassos commented on Oct 26, 2020

    @crtassos

    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

  9. HonmaMeikodesu commented on Jul 28, 2021

    @HonmaMeikodesu

    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

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    inspectorIssues and PRs related to the V8 inspector protocol.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions