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?
There is built-in command line debugger client within Node.js. Cloud 9 IDE have also pretty nice (visual) debugger.
Theseus is a project by Adobe research which lets you debug your Node.js code in their Open Source editor Brackets. It has some interesting features like real-time code coverage, retroactive inspection, asynchronous call tree.
There are many possibilities...
Debug support is often implemented using the v8 Debugging Protocol or the newer Chrome Debugging Protocol.
I put together a short Node.js debugging primer on using the node-inspector for those who aren't sure where to get started.
Use Webstorm! It's perfect for debugging Node.js applications. It has a built-in debugger. Check out the docs here: https://www.jetbrains.com/help/webstorm/2016.1/running-and-debugging-node-js.html
node-inspector could save the day! Use it from any browser supporting WebSocket. Breakpoints, profiler, livecoding, etc... It is really awesome.
Install it with:
Then run: