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
Debugger listening on ws://127.0.0.1:9229/3da188c5-8ab4-41e6-9fb2-2871638cb657
For help see https://nodejs.org/en/docs/inspector
App is listening on port 5000
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 !!!!