Thursday July 31, 2014 - tags:    node.js, node-inspector, v8-profiler

debugging node applications with node inspector

node-inspector does a pretty good job of debugging node applications; it utilises google chromes existing developer tools.

install v8 profiler

The first thing we need to do is install v8-profiler; which provides node bindings for integration with node-inspector

npm install -g v8-profiler  

install node inspector

Node Inspector is a debugger interface for Node.js applications that uses the Blink Developer Tools (formerly WebKit Web Inspector).

npm install -g node-inspector  


In order to run your application in debug mode:

node-debug app  

On your terminal you should see:

Node Inspector is now available from http://localhost:8080/debug?port=5858  
Debugging `app`

debugger listening on port 5858  

node-inspector will open a version of chromes developer tools fullscreen; on this url, http://localhost:8080/debug?port=5858 and will break on the first line of your application by default.

You have access to the complete set of developer tools; the left hand side displays the files in your application; the right the developer tools.

debugging tests

In order to debug mocha tests run:

node-debug _mocha  

In order to debug tap tests run:

node-debug your_test