Tuesday, October 24, 2017

Debugging Node.js application

Debugging Node.js app is always fun, especially if you're coming from other language background such as Ruby, Python. you may looking similar debugger(binding.pry or pdb) on node js world.

In this article, let me go through how debugging node.js app with Chrome DevTool

1. Install Node.js, i use nvm
$ nvm use v8.7.0
Now using node v8.7.0 (npm v5.4.2)

2. To start debugging mode, run the Node.js app with inspect flag 
node-app $ node --inspect index.js 
Debugger listening on ws://127.0.0.1:9229/a51c84e5-78c1-481e-ac5b-ab6bc78c23fe
For help see https://nodejs.org/en/docs/inspector
Debugger attached

3. Open Chrome inspector and click on "Open dedicated DevTools for Node" to debug your app code


Now you can debug your javascript code by adding breakpoint or "debugger"











Happy debugging :)

No comments:

Post a Comment