Node-debug — better node.js debugging GUI

Jesse Ditson
jesseditson
Published in
2 min readFeb 13, 2014

I often find myself working on node apps, and missing the robust runtime debugging that I get when working on Objective-C apps.

Node has some pretty solid debugging tools built right in, but they’re not the easiest to use.

There’s a fantastic project called node-inspector that solves most of the issues around the missing debug UI, but there are a few things that I find unwieldy about it. The basic way to get a debugger up with node-inspector would be the following:

  1. Open a terminal window, fire up node-inspector.
  2. Go back to what you’re working on, and start your app using the -debug flag.
  3. Copy paste the url output from node-inspector, open up a browser window, paste it in.
  4. Do your debugging
  5. Close your browser window, kill & close the node-inspector if you’re done debugging for the day.

I’m only interested in step 4 — so I figured I’d write some shell script wrappers to remove the other steps.

The result of that work is a simple bash script, packaged into an npm module. Here’s the gist, for your forking pleasure:

This script allows you to run:

node-debug somescript.jsnode-debug -brk somescript.js

Both commands will start an inspector session, background it, start your script, and open an incognito Chrome window pointed to the inspector. When you ^C your app, it traps the exit and closes the opened window (along with any other tabs on that same window), and kills the inspector.

node-debug is available on npm, and only compatible with OSX and Chrome at the moment, as it relies on some pretty hard coded osascript stuff. However, if your dev box looks like mine, you can just:

npm install -g node-debug-osx node-inspector

and node-debug will be available in your shell. Note that node-inspector & Google Chrome must both already be installed.

Note that there is another library on npm called node-debug, which is a less full featured wrapper around the same node-inspector. You’ll need to uninstall that if you’ve got it on your box, or just clone this repo and npm link it to another name.

As always, feature requests & forks are welcome. I’ll be adding to this little script when more robustness becomes necessary in my workflow!

Originally published at jesseditson.com on February 13, 2014.

--

--