Page tree
Skip to end of metadata
Go to start of metadata

Installation

Install Node Inspector as follows:

Starting the debugger

Icon

Node Inspector currently works only in the Google Chrome and Opera browsers. If you are using a different browser, reopen the Node Inspector page in one of those browsers.

First, start your Node application as usual; for example: 

Then run the debugger as follows:

This command starts Node Inspector and opens the interface at http://localhost:8080/debug?port=5858 in your default browser.

The slc debug command provides a number of options.  See slc debug for more information.  For additional configuration information, see the Node Inspector README.

If you don't want to run your application with the slc debug command, then you must use the node --debug-brk command to halt application execution on the first line.  This enables you to set breakpoints, step through the code, and debug the application.

Debugging a running application

To enable debugging on an application that is already running:

  1. Get the PID of the node process, for example: 

     
  2. Send he application the USR1 signal 

Icon

Windows does not support UNIX signals, so you must use a different technique. See the Node Inspector README for details.

Using Node Inspector

Using Node Inspector to debug a Node application is similar to debugging client JavaScript in Chrome. See Chrome DevTools > Debugging JavaScript for more information.

Node Inspector loads and parses files during a debug session and automatically adds them to the GUI. This is useful for –debug-brk and stepping through require() calls. 

Setting a breakpoint

To set a breakpoint in application code:

  1. Click on the "Show navigator" icon in the upper-left corner of the Node Inspector window to see a tree-list of all source files:
     
  2. Find the desired JavaScript file and double-click to open it.
  3. Click on the desired line number to set a breakpoint there. 
    Node Inspector highlights the line number in blue. 
     

Press F10 to step through Javascript statements.  Press F8 to resume script execution.

See the Chrome Developer Tools Guide for a walkthrough of other debugger features.  Node Inspector is based on Chrome Developer Tools and most features work exactly the same.

Breakpoints and uncaught exceptions

Node Inspector restores breakpoints after restarting an application and remembers your breakpoints in the browser's local storage (HTML5). When you restart the debugger process, or start debugging the same application after several days, Node Inspector restores the breakpoints.

You can also break on uncaught exceptions.  Node Inspector also provides integration with domains: exceptions handled by domain’s error handler are still considered uncaught. This feature requires Node.js v0.11.3 or greater.

Setting breakpoints in files not yet loaded

REVIEW COMMENT
Ask Miroslav to clarify. Feature isn't specific to mocha: it can happen with other test frameworks, or even just general code.  Separate the part that involves mocha as an example, and the general stuff,

Node Inspector enables you to set breakpoints in files that are not yet loaded into the V8 runtime.  

To do this, for example for Mocha unit tests:

  • Run mocha unit-test in any project with the –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.

Quick navigation shortcuts

You can navigate quickly by jumping to files and functions with keyboard shortcuts.  For example, jump to file with search: Command+O

Jump to member function with search: Command+Shift+O

See Keyboard shortcuts for a complete list of shortcuts.

Display and edit variables

Hover a variable to display and edit its value, as illustrated below:

Support for source maps

Node Inspector supports source maps, enabling you to keep client-side code readable and debuggable even when combined and minified, without impacting performance. For example, you can compile CoffeeScript, LiveScript or TypeScript files with source-map option turned on. Node Inspector will show you the CoffeScript, LiveScript or TypeScript source instead of trans-piled JavaScript. Also, you set breakpoints in these files.

Re-execute functions with "Restart Frame"

Right-click on a call frame (stack frame) in the right sidebar and select the ”Restart frame” command to re-execute the current function from the beginning.

Keyboard shortcuts

 

CommandMacWindows / Linux
Next Panel⌘]Ctrl-]
Previous Panel⌘[Ctrl-[
Toggle ConsoleEscEsc
Focus Search Box⌘FCtrl-F
Find Next⌘GCtrl-G
Find Previous⇧⌘GCtrl-Shift-G

Console keyboard shortcuts

CommandMacWindows / Linux
Next SuggestionTabTab
Previous Suggestion⇧TabShift-Tab
Accept SuggestionRightRight
Previous Command / LineUpUp
Next Command / LineDownDown
Previous Command⌃P 
Next Command⌃N 
Clear History⌘K or ⌃LCtrl-L
ExecuteReturnEnter

Debugger keyboard shortcuts

CommandMacWindows / Linux
Select Next Call Frame⌃.Ctrl-.
Select Previous Call Frame⌃,Ctrl-,
ContinueF8 or ⌘/F8 or Ctrl-/
Step OverF10 or ⌘’F10 or Ctrl-’
Step IntoF11 or ⌘;F11 or Ctrl-;
Step Out⇧F11 or ⇧⌘;Shift-F11 or Ctrl-Shift-;
Edit Breakpoint⌃ClickCtrl-Click