Currently it's possible to debug node scripts using Chrome as described here. However, if I run like this:
node --inspect --debug-brk myscript
It will only load myscript to the browser and I'll be able to put breakpoints in this file. But suppose that myscript requires anotherscript and I want to put a breakpoint in this script. I don't see how this can be done since Chrome inspector only loaded myscript.
Is there any way to load a file into Chrome inspector before this files is required in the script and Chrome loads it by itself?
I'm currently modifying sources and put debugger; statement there which works. But I was thinking that should be something more apt for this purpose.
It seems that it's currently not possible.
One possible solution to avoid modifying sources is to put a breakpoint at the end of the script. In this way the Chrome by the time the breakpoint is reached and the execution is paused Chrome will have loaded all relevant files. You can then open any file using Ctrl+P and put a breakpoint there. Chrome keeps breakpoints between sessions if you use Open dedicated Chrome DevTool for Node option:

Then simply restart you node application. See more details in the This will make you more efficient at debugging Webpack unspecified build errors article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With