简体   繁体   中英

Debugging script using node-inspector is not working

I am trying to debug a very simple script using "node-inspector". I tried both following instructions on the repo , which include running "node-debug" and instructions here which include running "node --debug-brk yourApp.js".

The main problem is that neither of the commands "node", "node-debug" or "node-inspector" return any result. They just return silently.

Running "nodejs --debug-brk myScript.js" on the other hand works, but does not seem to have a nice debug GUI. I can connect to it on http://127.0.0.1:5858/ but it is hardly useful for variable inspection.

Once you've installed node-inspector globally (with npm install -g node-inspector ) you can use it to connect to a nodejs process that's been run in debug mode. Try the following steps.

  1. Open two terminal windows
  2. In the first, run your process you'd like to debug with node --debug-brk myscript.js
  3. In the second, run node inspector with node-inspector
  4. In Chrome, visit the following address: http://localhost:8080/debug?port=5858

What you've done here is start node in debug mode (at port 5858 by default), then launch node inspector, which runs its own webserver on port 8080. The URL (the debug?port=5858 part) is telling node-inspector to connect to the node debug process that's on port 5858. Once you're in there, you'll see that your process has stopped on the first line (as instructed to by --debug-brk ). You can then set any other breakpoints you'd like, then press the "play" button to start your process running!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM