I recently gave a quick talk on debugging Node.js programs with Chrome Dev tools at NodeSchool Toronto! It was based on a great Medium post by Paul Irish.
It’s never been easier to debug your Node.js programs and servers! Here’s what I covered in my presentation:
Get a newer version of node.js:
-
use node 6.3.0+ or use nvm: nvm install 6.3.0.
Run your script!
-
node --inspect test.js
If you want to set a breakpoint in the beginning of your script you must use the following flag: --debug-brk
.
Look for the url once your script starts:
-
chrome-devtools://...
Open that url and you will get to your DevTools!
I found that the DevTools integration gets even better by updating to even newer versions of Node (such as 6.6.0). To go beyond the basic debugging operations I would suggest reading this article to get a better understanding of various profilers.
Don’t forget about your local NodeSchool event, it’s a great time to hack on some Node.js!