How do I debug Node.js applications?
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?
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
Debugging
Profiling
node --prof ./app.js
node --prof-process ./the-generated-log-file
Heapdumps
Flamegraphs
Tracing
Logging
Libraries that output debugging information
Libraries that enhance stack trace information
Benchmarking
ab -n 100000 -c 1 http://127.0.0.1:9778/
Other
Legacy
These use to work but are no longer maintained or no longer applicable to modern node versions.
The V8 debugger released as part of the Google Chrome Developer Tools can be used to debug Node.js scripts. A detailed explanation of how this works can be found in the Node.js GitHub wiki.
There is also ndb, a command line debugger written in Node.js itself.
链接地址: http://www.djcxy.com/p/1514.html上一篇: 我如何开始使用Node.js
下一篇: 我如何调试Node.js应用程序?