DEV Community

Mitesh Kamat
Mitesh Kamat

Posted on

Debugging node js app


Almost every javascript page that we create can be debugged on browser.
We debug code for fixing any defect or to have a better code understanding. So, I was wondering what about node js. Can I inspect my nodejs app or express app?

I somehow didn't pay attention to this and used to write log statements inside my express app. Then, I referred node js official doc

1) Run your node js application using --inspect flag like
node --inspect filename.js

It shows
Debugger listening on ws://
For help see
App is listening on port 5000
Debugger attached.

2) Open a new tab in chrome and type about:inspect

3) Locate your file of interest under remote target.

4) click on “Open dedicated DevTools for Node” to start debugging.

The official doc also shows handy command line options.

That's it .. Enjoy debugging !!!!

Discussion (0)