Debug node.js using the node inspector

I am trying to debug my nodejs application using a node inspector. But Google Chrome does not show the code.

I use the following,

Node.js: v0.10.26

Express: 4.0.0

Node Inspector: v0.7.3

Google Chrome Version: 34.0.1847.131

This is what I do to start the debugger.

$ node-inspector Node Inspector v0.7.3 Visit http://127.0.0.1:8080/debug?port=5858 to start debugging. 

In another console

 $ node --debug app.js debugger listening on port 5858 $ 

Then they launched Google Chrome and went to

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

It opens a node inspector, but without code. All windows are empty.

Noticed that I do not get the "Express server listening on port 3000"

Tried everything as a node-inspector could not connect to node , but no luck

Failed to find out what I do not see. It would be great if you had any suggestions. I can debug my Node.js apps in Google Chrome.

+66
node-inspector
Apr 28 '14 at 12:19
source share
5 answers

Try running node --debug-brk app.js instead of --debug . Your application cannot pause before the node inspector connects to the node process. Using --debug-brk will cause node to break in the first line of your application and wait for the debugger connected to the process. Downloading the web interface node-inspector is what causes the node inspector to join your node process; why do you include the node debug port in the query string (localhost: 8080 / debug? port = 5858). You tell the node inspector which port it should extend and connect.

Here's an animated gif showing the full installation and launch of node-inspector.

In gif, I use the --debug flag because I am not debugging the code that runs immediately when it starts. I am debugging inside the request handler, which only starts when the page is requested. Thus, updating the page causes the node-inspector to break into this line.

I also put together a 15 minute YouTube tutorial some time ago.

http://youtu.be/03qGA-GJXjI

I hope this helps!

+120
Apr 28 '14 at 16:04
source share
— -

The default node indicator tries to preload all the code before launching the debug window. I had instances, the node inspector just freezes forever due to this preload. Fortunately, new versions have the ability to stop preload, thereby speeding up the loading of inspectors.

Try node-inspector --no-preload

+22
Apr 15 '15 at 22:53
source share

Standard remote debugging is completely broken in node 6.5. Instead, it replaced the new internal node function

 $ node --inspect --debug-brk build/server/server.js Debugger listening on port 9229. Warning: This is an experimental feature and could change at any time. To start debugging, open the following URL in Chrome: chrome-devtools://devtools/remote/serve_file/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node Debugger attached. 

See here - http://arveknudsen.com/?p=346%3Fpage_id%3D346&print=pdf - for more information

+5
Sep 15 '16 at 14:33
source share

enter image description here

On the left side of the Node Inspector tab, "Sources" there is a "box with a triangle" - the highlight says "Show Navigator". (See Figure above). Open this to find the files you want to debug, and place a breakpoint on the code that is not already running.

Also note: if you want to debug code that runs when node starts, you need to use the --debug-brk option at startup. Then, in the Node Inspector, you will need to launch the application ( F8 to start everything). You will need this option if you want to debug all initialization code, for example, launch a web browser.

0
Apr 28 '14 at 16:02
source share

node-debug --no-preload app.js

This is what works for me. Following this :

My script is running too fast to enable a debugger.

The debugged process should be started with --debug-brk, so the script pauses in the first line.

Note: node-debug adds this option by default.

0
Nov 28 '17 at 8:16
source share



All Articles