Node Inspector is a debugger interface for nodeJS using the WebKit Web Inspector.
A WebKit based browser: Chrome, Safari, etc.
Optional v8-profiler to use the profiles panel
$ npm install -g node-inspector
To use node-inspector, enable debugging on the node you wish to debug. You can either start node with a debug flag like:
$ node --debug your/node/program.js
or, to pause your script on the first line:
$ node --debug-brk your/short/node/script.js
Or you can enable debugging on a node that is already running by sending it a signal:
Get the PID of the node process using your favorite method.
ps -ef are good
$ pgrep -l node 2345 node your/node/server.js
Send it the USR1 signal
$ kill -s USR1 2345
Great! Now you are ready to attach node-inspector
start the inspector. I usually put it in the background
$ node-inspector &
open http://127.0.0.1:8080/debug?port=5858 in your favorite WebKit based browser
select a script and set some breakpoints (far left line numbers)
then watch the screencasts
For more information on getting started see the wiki
node-inspector works almost exactly like the web inspector in Safari and Chrome. Here's a good overview of the UI
I don't see one of my script files in the file list.
try refreshing the browser (F5 or command-r)
My script runs too fast to attach the debugger.
--debug-brkto pause the script on the first line
I got the ui in a weird state.
when in doubt, refresh
Can I debug remotely?
Yes. node-inspector must be running on the same machine, but your browser can be anywhere. Just make sure port 8080 is accessible
--web-port=[port] port to host the inspector (default 8080)
This is beta quality code, so use at your own risk:
VERY EXPERIMENTAL I don't recommend using this yet
To use the profiles panel, install the v8-profiler module:
npm install v8-profiler
To use it do something like:
var profiler = ;profiler;;profiler;profiler;;profiler;
Then view the profiling results with the profiles panel in node-inspector. You can also take heap snapshots on demand from the profiles panel.
This project respectfully uses code from and thanks the authors of: