How to debug Node.js with Chrome


This post goes over how to debug Node.js with Chrome.

inspect

Launch the internal debugger of Node.js:

node inspect <file>

--inspect

Enable Node.js inspector by running your node script with the --inspect option:

node --inspect <file>

To launch the V8 inspector for use with Chrome Dev Tools:

  1. Open Chrome browser
  2. Go to chrome://inspect
  3. Click inspect under Remote Target

If you add debugger to your code and rerun your script with inspector, it will stop at the breakpoint.

--inspect-brk

Similar to --inspect except it breaks before the user code starts:

node --inspect-brk <file>


Please support this site and join our Discord!