If you’re developing with node, and you’re not using node-inspector, you should start right now.
Getting started is a breeze:
$ npm install -g node-inspector
$ node --debug your/short/node/script.js
I like to start with a break on the first line.
$ node --debug-brk your/short/node/script.js
I created a short script so I don’t forget:
|
1 2 |
#!/bin/bash node --debug-brk $1 |
Then run:
$ node-inspector
The output should give you a url you can hit with any webkit browser to pull up the same in-browser debugging console that you get when you’re debugging your JavaScript in webkit inspector (I use Chrome’s debugger).
Interactive stack traces with TraceGL
Tracegl – interactive stack traces. (Worth every penny)
TraceGL gives you interactive access to your full stack trace, including variable values, as the program is running. You can scroll up and down, zoom in and out, click through the callstacks, explore function bodies, and even see clearly which branches executed, and which didn’t. It has changed the way I debug JavaScript. Highly recommended.
More Node debugging resources
- Node Debugger (Built in command-line debugger)
- Debugging Production Systems (video talk)
- DTrace Your Node.js JS (slides)
- node-panic – Instrumentation for debugging your JS code
- Node Segfault Handler – For debugging native code