In this post, I want to outline how to debug Node.js applications. I tried a few different debug tools for Node.js but I found node-inspector to be a decent tool to debug Node.js applications.
First, install node-inspector:
npm install -g node-inspector
Start your Node.js application with –debug-brk which tells the debugger to pause your script on the first line:
node --debug-brk yourNodeApp.js
Go to http://127.0.0.1:8080?debug=port=5858. Last time I tried, IE did not work, so try with a non-IE browser.
At this point, you should see your Node.js script stopped on the first line. Click on scripts tab to see all your scripts and set breakpoints where ever you want and then step through your code like you normally would.