TIL: Debugging Node.js With the Built-in Inspector
console.log debugging works until it does not. When you need to inspect variables mid-execution or step through logic, Node’s built-in inspector is faster than adding log statements and re-running.
node --inspect-brk server.js
Debugger listening on ws://127.0.0.1:9229/abc123
Open Chrome and go to chrome://inspect. Your Node.js process appears under Remote Target. Click inspect and you get the full DevTools suite: breakpoints, watch expressions, call stack, heap snapshots.
node --inspect-brk server.js
The –inspect-brk flag pauses on the first line so you can set breakpoints before the code runs. No IDE required, no VS Code config, just Chrome and your terminal.
Is there a CLI debugger?
Yes. Use node inspect server.js for a terminal-based debugger. It supports the same commands but without the graphical interface.