Node.js : Debugging Your NodeJS Application

You can use the node-inspector. Run this command to install it via npm:

npm install -g node-inspector

Then you can debug your application using

node-debug app.js

The Github repository can be found here: github.com/node-inspector/node-inspector

Debugging natively You can also debug node.js natively by starting it like this:

node debug your-script.js

To breakpoint your debugger exactly in a code line you want, use this:

debugger;

If you've older version of node.js for example in node.js 8 use the following command:

node --inspect-brk your-script.js

Then open about://inspect in a recent version of Google Chrome and select your Node script to get the debugging experience of Chrome's DevTools.

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.

Buy Me A Coffee