node.jsnode-inspector

node-inspector fails to connect to node


I run node with

node --debug app
OR
node --debug-brk app

it responds

debugger listening on port 5858
Express server listening on port 1338

I now start node-inspector

node-inspector --web-port=5859

It responds with

Node Inspector v0.3.2
info  - socket.io started
Visit http://127.0.0.1:5859/debug?port=5858 to start debugging.

Open chrome and go to

http://127.0.0.1:5859/debug?port=5858

Console logs the following

enter image description here

Using TCPview, it shows node is listening to port 5858 but it has no established connection. When the connection is attempted this message appears on the node console

}Content-Length: 108

Nothing else. I then tried to get the debugger to run on a different port:

node --debug=5000 app
node-inspector --debug-port=5000 --web-port=5859 

but node-inspector would not connect EDIT: Well the error is not with node. I installed the Eclipse node environment and was able to debug. Decided to give node-inspector the benefit of the doubt and reinstall.

npm uninstall node-inspector
npm WARN uninstall not installed in C:\Program Files\nodejs\node_modules: "node-inspector"

re-installed node re-installed chrome No luck same problem.

So Eclipse it is.


Solution

  • With your first attempt, you're telling node-inspector to try to connect to the debugger on 5859 (not default), then telling node debugger to listen on the default 5858.

    Start node: node --debug-brk app.js and it will run the debugger on 5858.

    Start node-inspector: node-inspector and it will try to connect to 5858.

    Open your browser to the provided url to access the web interface and the browser should load up the sources panel and execution should be halted on the very first line of your app.

    In your second attempt, your approach looks okay, and having used node-inspector for a year (presently struggling with 0.12.3), I'd say it was likely node-inspector causing the issue there.