What does the Node.js `--nolazy` flag mean?

node.jsNode Debugger

node.js Problem Overview


When I use --nolazy, I can finally debug asynchronously with IntelliJ, as breakpoints stop at the correct place. But I can't find any docs on --nolazy...

What does --nolazy mean?

node.js Solutions


Solution 1 - node.js

To let anyone know, if you debug node js (especially remote debug) and use async type coding which you kind of have to as this is the nature of node, you will to run node with the flag of -nolazy

node --nolazy --debug-brk sample1.js

this will force V8 engine to do full compile of code and thus work properly with IntelliJ and WebStorm so you can properly place breakpoints in the code and not have to use the ;debugger; string which v8 looks for...

hope this helps someone, sure helped me :)

Sean.

Solution 2 - node.js

As others have said, you can see command line options for v8 with

node --v8-options

There, you can see a listing for --lazy:

--lazy (use lazy compilation)
      type: bool  default: true

v8 uses a fairly common way to describe booleans - prefix the flag with no to set to false, and use just the flag to set to true. So --nolazy sets the lazy flag to false.

Note: node uses a slightly different convention - there, you use the no- prefix (note the dash) to set bools to false. For example, --no-deprecation is a node flag.

Solution 3 - node.js

refer to: https://vscode-docs.readthedocs.io/en/stable/editor/debugging/

For performance reasons Node.js parses the functions inside JavaScript files lazily on first access. As a consequence, breakpoints don't work in source code areas that haven't been seen (parsed) by Node.js.

Since this behavior is not ideal for debugging, VS Code passes the --nolazy option to Node.js automatically. This prevents the delayed parsing and ensures that breakpoints can be validated before running the code (so they no longer "jump").

Since the --nolazy option might increase the start-up time of the debug target significantly, you can easily opt out by passing a --lazy as a runtimeArgs attribute.

Solution 4 - node.js

  • Problem: when you want to set breakpoints in ides to debug js codes in nodejs, some breakpoints doesn't work.

  • Reason: On start, node parses the code lazily, it means it doesn't see the full code. so it doesn't see all of the breakpoint.

  • Solution: Use --no-lazy option to turn of the node's lazy behavior.

( Ps: i tried to explain it easily and it may not be so accurate. )

Solution 5 - node.js

Run

node --v8-options

it will show you all available flags.

btw: closest flag I have found for you is

--lazy

means lazy compilation, which I believe is obvious by name

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionborn2netView Question on Stackoverflow
Solution 1 - node.jsborn2netView Answer on Stackoverflow
Solution 2 - node.jsAaron DufourView Answer on Stackoverflow
Solution 3 - node.jsscolooView Answer on Stackoverflow
Solution 4 - node.jsyayaView Answer on Stackoverflow
Solution 5 - node.jsEugene P.View Answer on Stackoverflow