How to debug a basic node.js application (not http) on windows

To use node-inspector, the right switch is node --debug not node debug

Here are the detailed steps:

  1. install node-inspector globally (npm install -g node-inspector)
  2. from a command-line window, run: node-inspector
  3. open Chrome and go to http://localhost:8080/debug?port=5858. You'll get the node-inspector UI but without any running app.
  4. from another command-line window, run your app with the --debug switch like this: node --debug test.js
  5. refresh the Chrome tab and voila!

A few interesting points:

  • If you kill your app and start it again, just refresh the node-inspector tab. It will keep all your breakpoints.
  • To break automatically on the first line start your app with node --debug-brk test.js

Some links which might help you:

  • http://vimeo.com/19465332 (screencast from Ryan himself).
  • https://github.com/joyent/node/wiki/using-eclipse-as-node-applications-debugger

It says: debugger listening on port 5858

I wondered myself about this but since the Node.js documentation indicates that the debugger is accessible via a simple TCP protocol and says nothing about HTTP my guess is that no, it won't be available at _http://localhost:5858.

"V8 comes with an extensive debugger which is accessible out-of-process via a simple TCP protocol" - http://nodejs.org/api/debugger.html