node.jsnode-inspector

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


I know how to debug http applications using node-inspector and iisnode. But can I use node-inspector to debug a non http node application, on windows?

I tried:

 node debug test.js

It says:

debugger listening on port 5858

But opening http://localhost:5858/ in Chrome does not do anything.


BTW: running node debug test.js does start the command-line debugger which works. But it's nothing like node-inspector.


Solution

  • 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: