DEV Community

RajeshKumarYadav.com
RajeshKumarYadav.com

Posted on • Updated on

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
Enter fullscreen mode Exit fullscreen mode

Then you can debug your application using

node-debug app.js
Enter fullscreen mode Exit fullscreen mode

The Github repository can be found here: https://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
Enter fullscreen mode Exit fullscreen mode

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

debugger;
Enter fullscreen mode Exit fullscreen mode

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

node --inspect-brk your-script.js
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)