Reputation: 3857
When I start my app using 'npm start'
at the command line I can browse it at :3000
.. but not when I start it using 'node app.js'
when I try 'node --debug app.js'
I get a console window with the message
"Debugger listening on port 5858"
With Visual Studio and the node toolkit I get the same. With Eclipse and Enide I get the same.
I've tried using Nodes built in command line debugger, but after the debug> prompt appears issuing the continue or next step commands does nothing, and I can't browse the app at :3000
I've installed node-inspector, and after 'node --debug app.js'
I can see app.js in the node-inspector chrome tab :8080, but can't browse my app at :3000 and can't get breakpoints to work.
I guess that to get debugging working I need 'node app.js'
to run, and not be using 'npm start'
..
What important node configuration detail have I missed?
Why is my app not browsable when using 'node app.js'
?
Any advice is appreciated..
Upvotes: 0
Views: 5414
Reputation: 6086
Your actually starting the app in two differnet ways using different code - one which includes the debugger and one that does not.
If your running a default Express 4 setup, if you check the package.json file you will see this section:
"scripts": {
"start": "node ./bin/www"
}
That is the file that is executed when you run npm start
, so running node app.js
is actually a different script.
If you take a look at bin/www
you will see the debugger is invoked:
var debug = require('debug')('myapp');
To run use:
DEBUG=myapp ./bin/www
If you are starting using NPM, you can add it to the package.json or use exactly the same command from the cmd line:
"scripts": {
"start": "DEBUG=myapp node ./bin/www"
}
Upvotes: 2