Over the years, Node developers have come to rely on Danny Coates’ node-inspector npm module to debug their applications. While popular, the community has nonetheless been clamoring for additional features. Node-inspector has also been in need of an infrastructure refresh with Google abandoning support for WebKit awhile back.
Check out the video to see node-inspector in action.
Supported in StrongNode
Node-inspector now ships as a supported module of the StrongNode distribution. We added a new command to our `slc` tool which simplifies the process of setting up all components required to debug your application.
Starting up a debugger could not be easier now, just type:
$ slc debug app.js
…to have your application started in debug mode. Node-inspector will start in the background and a new browser window will be opened with the node-inspector GUI.
Please note that node-inspector GUI works in Google’s Chrome browser only. If you have a different browser configured as the default, you will have to manually reopen the GUI in Chrome.
Set BreakPoints in Files Not Yet Loaded
The most popular enhancement request we got the over last few months was the ability to set breakpoints in a file not yet loaded. Ask and you shall receive! It’s live in the latest release. Here’s how to demo it for yourself:
- Run mocha unit-test in any project with –debug-brk option.
- Launch node-inspector.
- Look at source files of your unit-tests and set breakpoints inside them.
- Resume execution when you have all breakpoints set up
- Wait for debugger to hit your first breakpoint.
Here’s a partial list of some the other new features in the debugger:
Improved GUI, backed by Blink
Previously, the node-inspector GUI was based on a Webkit Inspector version from September 2011. Despite there being many improvements implemented in Webkit Inspector over the last two years. In April 2013, Google decided to abandon Webkit project and start Blink – a Webkit fork focused on Chrome/Chromium needs. The new version of node-inspector GUI is based on the Blink DevTools (the successor of Webkit Inspector). This way node-inspector has all features that were implemented in Webkit Inspector in the last two years and it should be fairly easy to include new features that Google adds to Blink DevTools in the future. Notice that source files are now organized into a hierarchical tree!
Breakpoints and Uncaught Exceptions
Breakpoints are now restored after restarting of debugged application. Node-inspector will now remember your breakpoints in the browser local storage (HTML5). When you restart the debugger process, or even start debugging the same application after several days – your breakpoints are restored!
You can now break on uncaught exceptions. The ultra-cool thing is the integration with domains – exceptions handled by domain’s error handler are still considered as uncaught. Please, note that this requires Node.js v0.11.3. So, if you want some of this debugging goodness, you’ll need to upgrade.
Automatically Load and Parse Files in a Debug Session
Files are now loaded and parsed during a debug session and automatically added to the GUI. This is useful for –debug-brk and stepping through require() calls. The previous version of node-inspector was not updating the list of files in the browser. This meant you had to reload the node-inspector page each time to see an updated list.
Quick Navigation Shortcuts
Quick navigation by jumping to files and functions easily with shortcuts. You can now:
Jump to file with search: Command+O
Jump to member function with search: Command+Shift+O
Display and Edit Variables
You can now hover a variable to display and edit its value.
Support for Source Maps
Re-execute functions with “Restart Frame”
You can now right-click on a call frame (stack frame) in the right sidebar and select the ”Restart frame” command. This re-executes the current function from the beginning.