Debug the Node.js server with Chrome DevTools by passing the --inspect
flag:
$ node --inspect server.js
Debugger listening on ws://127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
For help, see: https://nodejs.org/en/docs/inspector
Open chrome://inspect/#devices
in your Chrome browser and inspect the target.
Chrome DevTools will open in a new window and your Terminal will log Debugger attached.
.
When you go to http://localhost:8080/
, the debugger will break at the breakpoint.
See Debugging Guide for more information.