Node.js debugger based on Blink Developer Tools
Перейти к файлу
Miroslav Bajtoš de14ca3951 Update list of scripts on afterCompile event.
Added afterCompile listener that registers
newly parsed/loaded script. Includes

- refactoring of script registration
  (extracted class ScriptManager).

- fix of script path shortening, where windows paths
  containing '\' instead of '/' were not shortened
  at all.
2013-05-17 20:46:40 +02:00
bin configure which interface to listen on so that we can avoid opening the debugger to the world if not needed 2012-02-10 15:38:37 -05:00
front-end Added meta tag to enable IE support via Chrome Frame 2011-10-26 20:33:32 -07:00
lib Update list of scripts on afterCompile event. 2013-05-17 20:46:40 +02:00
test Update list of scripts on afterCompile event. 2013-05-17 20:46:40 +02:00
.gitignore Switched to socket.io - fixes #56 2011-09-02 20:31:39 -07:00
ChangeLog version 0.1.10 2011-09-02 20:46:37 -07:00
LICENSE Added BSD License 2011-10-22 19:03:07 -07:00
config.json default should be backwards compatible 2012-02-13 13:30:07 -05:00
package.json Restore breakpoints on debugee restart. 2013-05-17 20:46:40 +02:00
readme.md updated 'Thanks' on readme 2011-09-03 13:00:29 -06:00

readme.md

Node Inspector is a debugger interface for nodeJS using the WebKit Web Inspector.

Getting Started

Requirements

  • nodeJS

    • versions: 0.3.0 or later
  • npm

  • A WebKit based browser: Chrome, Safari, etc.

  • Optional v8-profiler to use the profiles panel

Install

  • With npm

      $ npm install -g node-inspector
    

Enable debug mode

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:

  1. Get the PID of the node process using your favorite method. pgrep or ps -ef are good

     $ pgrep -l node
     2345 node your/node/server.js
    
  2. Send it the USR1 signal

     $ kill -s USR1 2345
    

Great! Now you are ready to attach node-inspector

Debugging

  1. start the inspector. I usually put it in the background

     $ node-inspector &
    
  2. open http://127.0.0.1:8080/debug?port=5858 in your favorite WebKit based browser

  3. you should now see the javascript source from node. If you don't, click the scripts tab.

  4. select a script and set some breakpoints (far left line numbers)

  5. 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

FAQ / WTF

  1. I don't see one of my script files in the file list.

    try refreshing the browser (F5 or command-r)

  2. My script runs too fast to attach the debugger.

    use --debug-brk to pause the script on the first line

  3. I got the ui in a weird state.

    when in doubt, refresh

  4. 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

Inspector options

--web-port=[port]     port to host the inspector (default 8080)

Cool stuff

  • the WebKit Web Inspector debugger is a great js debugger interface, it works just as well for node
  • uses WebSockets, so no polling for breaks
  • remote debugging
  • javascript top to bottom :)
  • edit running code

Known Issues

This is beta quality code, so use at your own risk:

  • be careful about viewing the contents of Buffer objects, each byte is displayed as an individual array element, for anything but tiny Buffers this will take too long to render
  • while not stopped at a breakpoint the console doesn't always behave as you might expect

Profiling

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 = require('v8-profiler');

profiler.startProfiling('startup');
slowStartupFoo();
profiler.stopProfiling('startup');

profiler.takeSnapshot('beforeLeak');
leakyFoo();
profiler.takeSnapshot('afterLeak');

Then view the profiling results with the profiles panel in node-inspector. You can also take heap snapshots on demand from the profiles panel.

Thanks

This project respectfully uses code from and thanks the authors of: