Noob To Neptune : Node Debugging Trident
JavaScript's rising popularity has brought a lot of changes. Embracing the ‘Good Parts’ and avoiding the ‘Bad Parts’ has been the mantra to JavaScript success for quite a long time. But this particular language is moving like a peregrine falcon which brings along a truck-load of libraries, frameworks, tooling, etc… changing the definition of a language ninja and summing up the JavaScript learning to ‘Adapt or Perish’. As we all know Node.js unleashed JavaScript outside the browser. Beyond that, it’s worth noting that Ryan Dahl, the creator of Node.js, was aiming to create real-time websites with push capability, “inspired by applications like Gmail”. In Node.js, he gave developers a tool for working in the non-blocking, event-driven I/O paradigm.
But this article is not about learning Node.js and specifically aimed at one of the most agonizing subjects i.e. debugging Node.js.
This is a getting started article which provides an unopinionated view at three ways of debugging node.js using:
node-inspector
This is undisputedly the most popular node.js debugger out there. Node Inspector works exactly like Chrome Developer Tools which is one of the reasons for its popularity. It provides exactly the same experience as front-end debugging with features including CPU & HEAP profiling and Network client requests inspection. It also supports live edit of running code, optionally persisting changes back to the file-system.
Node Inspector works on WebSockets which enables remote debugging of code without polling.
Install
npm install -g node-inspector
Start
node-debug app.js
where app.js is the name of the main JavaScript file.
There is a suite of configuration settings which can be applied with debugging.

Node Inspector uses ‘ — debug-brk’ by default which pauses the execution on the first line allowing setting up of break point in the codebase.
Features:
- Navigate in your source files
- Set breakpoints (and specify trigger conditions)
- Step over, step in, step out, resume (continue)
- Inspect scopes, variables, object properties
- Hover your mouse over an expression in your source to display its value in a tooltip
- Edit variables and object properties
- Continue to location
- Break on exceptions
- Disable/enable all breakpoints
- CPU and HEAP profiling
- Network client requests inspection
- Console output inspection
iron-node
According to Stephan Ahlf,
I always hated attaching processes, watching files, restart processes and so on to debug Node.js code. For this reason I wrote this software to make those things easier. With ironNode you have the full power of JavaScript debugging within Chrome Developer Tools.
I cannot agree more with the agony of Stephan when it comes to node.js debugging and ironNode tries to addresses almost all of them. Unlike node-inspector ironNode doesn’t use WebSockets as it works independent of local node.js installation. It has its own node.js version which make things blazing fast. This project has been gaining a lot of popularity lately and is poised to become the go-to node.js debugger. This is easy, fast and smooth.
ironNode supports both local(local directory) and global(ironNode’ s AppData folder) configuration using configuration file called .iron-node.js which along all other thing allows setting up v8-flags. Debugging Grunt, Gulp, Mocha and other command-line node.js tasks are pieces of a cake on ironNode.
Install
npm install iron-node -g
Start
iron-node app.js
where app.js is the name of the main JavaScript file.
iron-node PATH_TO_NODE_JS_FILE [--customparm1=foo --customparm2=bar];
Unlike node-inspector, ironNode doesn’t use ‘ — debug-brk’ so use ‘debugger;’ in the main JavaScript file.

Features:
- ECMAScript 6 support out the box without any precompilers. (io.js under the hood).
- Easy to restart a project using ctrl+r
- Fast start-up.
- Support for almost all the features of node-inspector except remote and cluster debugging (by design).
Visual Studio Code
This light-weight editor by Microsoft provides a very sleek and smooth node.js development experience with an in-built node.js debugger. The debugger is very basic but gets the job done for most of the application development needs.
To debug node.js application we need to configure how the application will be started by creating a ‘launch.json’ file.

VS Code has a debug view which can be accessed by clicking on the ‘Debug’ icon in the view bar.

This view provides a Configure gear icon clicking on which will scaffold a ‘launch.json’ file (in the folder ‘.vscode’) with all the default values to launch an application. Making changes to this file is easy and intuitive. After making the necessary changes to this file and placing the required break-points in the source files click on the ‘play’ icon on the top-left corner to launch the application in debug mode.

Features:
- In-built (no need to leave the editor).
- Easy-to-use step over, step in, step out, continue and restart buttons.
- Look at local, script and global variables while debugging.
- Call stack view.
- Hover your mouse over an expression in your source to display its value in a tool-tip.
- Edit variables and object properties
- Expression watch support (add and remove expressions).
- Debug console to look at the console outputs.
- Break on exceptions.
- Disable/enable all breakpoints.
There you have it, hopefully this article provided you with some insights at debugging node if not as transforming as noob to neptune (thought it would be catchy) … ;-) .
I have ditched a lot of IDEs after moving from .Net to Node as they seem to be slow, heavy and full of cramps when it comes to JavaScript debugging in general though I would like to make some honorable mentions such as Visual Studio and WebStorm.
Happy Debugging…Cheers :)