How do I debug a Node.js server application?
Right now I'm mostly using alert debugging with print statements like this:
sys.puts(sys.inspect(someVariable));
There must be a better way to debug. I know that Google Chrome has a command-line debugger. Is this debugger available for Node.js as well?
js Debugger. Node. js provides built-in non-graphic debugging tool that can be used on all platforms. It provides different commands for debugging Node.
The V8 debugger can be enabled and accessed either by starting Node with the --debug command-line flag or by signaling an existing Node process with SIGUSR1. Then run node-inspector and browse to the URL it indicates.
Remote debugging and debugging remote machine. Live edit of running code, optionally persisting changes back to the file-system. Set breakpoints in files that are not loaded into V8 yet - useful for debugging module loading/initialization. Embeddable in other applications - see Embedding HOWTO for more details.
node-inspector could save the day! Use it from any browser supporting WebSocket. Breakpoints, profiler, livecoding, etc... It is really awesome.
Install it with:
npm install -g node-inspector
Then run:
node-debug app.js
node --prof ./app.js
node --prof-process ./the-generated-log-file
Libraries that output debugging information
Libraries that enhance stack trace information
ab -n 100000 -c 1 http://127.0.0.1:9778/
These use to work but are no longer maintained or no longer applicable to modern node versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With