Search code examples
javascriptnode.jsdebuggingnode-inspectornode-debugger

Can't get node-debug to work


This feels really silly, but I can't get node inspector / node-debug to work.

The instructions say to do npm install then to run node-debug web.js. So I did that. Now I have a lovely browser window open showing me my code with breakpoints... and no idea which url to use to actually access the code.

The inspector is at http://localhost:8080/debug?port=5858 and the terminal says:

> node-debug web.js
debugger listening on port 5858
Node Inspector is now available from http://localhost:8080/debug?port=5858
Debugging `web.js`

...

I've tried hitting up localhost:5000 (which is my express.js port) but that either fails if I don't have a separate node web.js instance running, or it succeeds if I have the other one running but doesn't trip any of the breakpoints in the inspector.

When I go to http://localhost:5858/, I get:

Remote debugging session already active

When I go to http://localhost:8080/, I get:

Cannot GET /

(the / path totally works on my server in general.)


Solution

  • By default node-debug starts app in --debug-brk mode. This stops your app at first line (express not started).

    You can use node-debug --no-debug-brk see the node-debug --h for more info.