I'm trying to use node-debug
to debug my CLI node script. According to everything I've read, I should simply be able to run my script with node-debug
, which will start the script with --debug-brk
, and open my browser to the node-inspector
page.
This all seems to be working fine. I see no output from my script (which indicates the --debug-brk is working), my browser opens, it is connected to node-inspector
, and if I kill node-debug
, the inspector shows it gets disconnected.
But the inspector interface is empty. There's no code. No stack trace. Nothing.
There aren't a lot of options to node-debug
, and none of them look like they would fix the problem I'm having.
node-debug myscript.js
output
debugger listening on port 5858
Node Inspector is now available from http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858
Debugging `myscript.js`
inspector Dev console
Assertion failed: Unknown experiment canvasInspection
TypeError: Cannot read property 'createSetting' of undefined
That is the legacy debugger, which had a somewhat rickety foundation to begin with and has since fallen out of sync with what Chrome uses for communication and has been deprecated for a while.
You should instead use the newer built-in inspector via the --inspect
flag.
node --inspect myscript.js
There is a userland package, inspect-process, which makes the experience even nicer and works around some potential problems you may run into.
https://nodejs.org/en/docs/guides/debugging-getting-started/
https://blog.risingstack.com/how-to-debug-nodej-js-with-the-best-tools-available/
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