Debug Node.js with Chrome DevTools

Prerequisites

  • Node.js 6.3+;
  • Chrome 55+;

Configure Chrome (Latest versions no longer need this step);

  1. Enter URL: chrome://flags/#enable-devtools-experiments to enter Developer Lab

  2. Enable highlighted option

  3. Restart Chrome

  4. Open DevTools Setting -> Experiments;

  5. Press Shift 6 times consecutively to show hidden options

  6. Find Node debugging and check it. (New versions no longer have this option, it’s enabled by default. So Chrome doesn’t need configuration)

Run Node.js

Just add –inspect to the command, followed by the file you want to execute;

node --inspect app.js 

Copy the console output:

chrome-devtools:// protocol address

chrome-devtools://devtools/remote/serve_file/xxxxxxxxx

Paste it into the browser address bar, and you can use Chrome’s console to debug your node application.

Article Link:

https://alili.tech/en/archive/bd292cd9/

# Latest Articles