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

后端 未结 5 884
無奈伤痛
無奈伤痛 2021-02-01 13:28

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

5条回答
  •  清歌不尽
    2021-02-01 13:47

    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.

提交回复
热议问题