Aaron Shen
Aaron Shen

Reputation: 8404

what's the right process to debug with node-inspector?

I'm on node version v5.0.0. I installed node-inspector version: v0.12.5.

what I did:
1st. I start node-insepctor on port 8090 (due to 8080 is taken by nginx)

node-insepctor --web-port=8090

2nd. I start debugging my js file

node --debug-brk app.js

3rd. I open the url in browser

http://127.0.0.1:8090/?ws=127.0.0.1:8090&port=5858

It works for the 1st time, it will perfectly break at the first line. But after I find and fix the issue in my code and I want to debug again, it just can't works again.

What I tried:

1st. I see that in the console, the following line which printed when I node --debug-brk app.js is still there:

Debugger listening on port 5858

So I refresh the page, the code is shown, but it just doesn't get executed, so no break point is reached.

2nd. I stop the app.js debug process by CTRL-c, and restart debugging app.js, Debugger listening on port 5858 is shown again. so I open the url again. same as above, the code is shown, but nothing happens.

3rd. I stop both the node-inspector process and app.js debug process and restart them both and open the url. this time, it works!!

Is there an easy way to debug a js program more than once??
Every time I need to kill both node-inspector process and debug js process to make it work again??
Or I'm doing something wrong here??

Please help!

Upvotes: 2

Views: 239

Answers (1)

gnerkus
gnerkus

Reputation: 12037

node-inspector can be executed with the node-debug <file> command which adds the --debug-brk option by default. This opens the file in the Sources tab and breaks on the first line.

To continue debugging, you'll need to follow the steps below:

  1. Select the file you need to debug from the Sources tab.
  2. Click on a line number of the file to set a breakpoint.
  3. Resume script execution (F8). This will cause the execution to break on the line that was highlighted in step 2.

Upvotes: 1

Related Questions