Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable in the node debugger "break on first line"

Is there a command line argument or an environment variable that disables the "break on first line" feature of the node debugger?

like image 327
4 revs, 2 users 76% Avatar asked May 07 '13 13:05

4 revs, 2 users 76%


People also ask

How do I disable debugger attached?

Just Delete the . vscode file from the directory you are working in and reopen the window the debugger will be gone.

How do I disable debug mode in Visual Studio code?

To enable or disable Just My Code in Visual Studio, under Tools > Options (or Debug > Options) > Debugging > General, select or deselect Enable Just My Code.

How do you breakpoint in node JS?

When debugging in Node. js, we add a breakpoint by adding the debugger keyword directly to our code. We can then go from one breakpoint to the next by pressing c in the debugger console instead of n . At each breakpoint, we can set up watchers for expressions of interest.

Which CLI option can you use to debug a node?

A minimal CLI debugger is available with node inspect myscript. js . Several commercial and open source tools can also connect to the Node. js Inspector.


1 Answers

There are actually two debugger concepts in node: V8 debugger (with its TCP-based protocol) and a node command-line debugger (CLI).

When you run node debug app.js, a debugger CLI is run in the master node process and a new child node process is spawned for the debugged script (node --debug-brk app.js). The option --debug or --debug-brk is used to turn on V8 debugger in the child process.

The difference between --debug and --debug-brk is that the latter one adds a breakpoint on the first line, so that execution immediately stops there.

I would suggest you this solution:

  1. When you are creating a child process from your webserver, run node --debug instead of node debug. This way there is only one child process created, it is running your application and it is not paused on the first line.

  2. Now you can use any debugging tool that supports V8 debugger protocol - node built-in CLI debugger, node-inspector or you can event implement your own debugger front-end (GUI) if you like. (I presume this is what you are trying achieve by running CLI debugger in background?)

    If you decided to use built-in CLI, just spawn another another child process and tell node CLI debugger to connect to the process started in step 1:

    node debug localhost:5858

    and continue as before.

like image 104
Miroslav Bajtoš Avatar answered Sep 29 '22 00:09

Miroslav Bajtoš