29

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.

asked Jul 11, 2012 at 17:18
1

7 Answers 7

64

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
answered Jul 13, 2012 at 2:17
Sign up to request clarification or add additional context in comments.

2 Comments

With the latest nodeJS on OSX, it seems that "node debug" does the right thing, and "node --debug" doesn't.
According to nodejs.org/api/debugger.html the difference of either version is about what node is expected to do: --debug will start some application to be debugged and debug will start node to debug some application. So these are two sides of the same story.
2
answered Jul 11, 2012 at 17:33

Comments

2

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

answered Jul 11, 2012 at 18:16

1 Comment

Good point about TCP vs HTTP. I know about the command-line debugger but it's really the node-inspector experience I'm looking for.
1

Very recently Microsoft released the node.js tools for Visual Studio. It has the very comfortable Visual Studio debugging for node.js.

answered Nov 25, 2013 at 11:14

Comments

0

node-inspector could be very helpful.

Use it from any browser supporting websockets.

Breakpoints, profiler, livecoding, etc..

http://erickrdch.com/2012/09/debug-a-nodejs-app-with-chrome-dev-tools.html

answered Jan 9, 2013 at 10:15

Comments

0

FYI, in OSX 10.8, Chrome v26 doesn't seem to work, but Safari 6 does using the same instructions as above and using 0.0.0.0:8080 to conect.

There is another post by Danny Coates somewhere that says to do it in the following order:

  1. Your node process: node --debug (or --debug-brk) my_program.js
  2. Node-inspector: node-inspector
  3. The browser pointed to 0.0.0.0:8080
answered Mar 13, 2013 at 0:24

Comments

0

If you are a noob like me on Windows, and you get 'node-inspector not recognized' or something about windows JScript error... despite global install, adding to PATH, etc. then this may help.

Navigate to C:\Users\urusername\AppData\Roaming\npm

Then run node-debug.cmd or node-inspector.cmd

You should get magical words like

Node Inspector v0.12.7
Visit http://127.0.0.1:8080/?port=5858 to start debugging.
Debugger listening on port 5858

Awesome. If you know of a better solution, please let me know

answered Apr 7, 2016 at 2:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.