Debugging Node/Express --- require('express') creates a break

My fairly limited experience with Node and Express doesn't help, but I'm having trouble debugging the app from the terminal window. Here is the issue:

running node debug app.js returns:

< debugger listening on port 5858
connecting... ok
break in server.js:1
    1 var express = require('express');

Is this the right way of debugging express apps?

There is a popular GUI debugger (leveraging WebKit, i.e. Chrome, Safari..).

You should give it a go https://github.com/dannycoates/node-inspector

Just echoing the call for Node Inspector with a bit more explicitness.

$ sudo npm install -g node-inspector
$ node-debug app.js <arguments to your app>
debugger listening on port 5858
Node Inspector is now available from http://localhost:8080/debug?port=5858
Debugging `app.js`

Now in (a webkit-based?) browser go to that address - or it works just fine remotely too, as long as the ports are open.

enter image description here

Now you have full access to all the server side variables (the app object for instance), exposed to the client side debugger. It's quite magical. You can set breakpoints at app.get() entry points, or at server init, or wherever.

Personally, I prefer to use a combination of node-inspector with old-fashioned console.log statements to figure out what's going on. (I don't think v8-profiler, mentioned by node-inspector, works with Node 0.6.x, but to be honest I haven't tried.)

If someone else has a better-maintained tool for debugging Node.js apps, I'd love to hear of it, too, but this is the best that I know of.