Lesson 25 / 28

Debugging Node

console methods and the built-in inspector.

Beyond console.log

console has more than log — use the right method for the job.

console.error("Something failed");   // to stderr
console.table([{ id: 1, name: "Ada" }]);
console.time("work");
// ...
console.timeEnd("work");             // work: 12.4ms

node --inspect

Attach Chrome DevTools to a running Node process for breakpoints, step-through, and heap snapshots.

node --inspect server.js
# then open chrome://inspect in Chrome

node --inspect-brk server.js   # pause on the first line