I have a basic express app that I am trying to debug but I cannot get node inspector working correctly on OSX
In one terminal window I run:
node --debug-brk server.js
In another terminal window I run:
node-inspector
Node Inspector opens here:
http://localhost:8080/debug?port=5858
In another browser tab I try to open my site here
http://localhost:8080/
I get printed to screen
Cannot GET /
If I open instead
http://localhost:3000
I get my app because I set this in server.js
app.set('port', process.env.PORT || 3000);
But now none of the breakpoints work in the debugger
I am sure I am doing something stupid here but I have read the docs and tutorials over and over and I cannot get this to work.
The other things I have tried is in one terminal window running:
node-debug server.js
I get the same thing as above. Debug inspector opens and is stopped at first line and my site at
http://localhost:8080
still says
Cannot GET /
I also tried
node-debug --no-debug-brk server.js
An I get the same result except node inspector in not stopped at first line
Debug inspector opens and is stopped at first line...
When node-inspector
starts debugging an application, by default, it stops at the first line, during the app starting process. If you try to access your app at http://localhost:3000
with the debugger stopped at the first line, you'll never get to your breakpoints.
Before trying anything, you must resume script execution or start node-inspector
with the --no-debug-brk
option, to prevent stopping at the first line.
To make sure node-inspector
is not stopping at any line at all, what you should do:
app.listen
call, or;