Debugging Node

View saved

Log with context

Print objects and labels so you know which step failed.

console.log("creating note", { text });
console.error("failed", err);

Use the inspector

Open Chrome DevTools against a Node process.

node --inspect app.js
# Then open chrome://inspect in Chromium/Chrome

Watch mode while learning

Node's built-in watch restarts on file changes.

node --watch app.js

Reproduce first

Note the exact request, env vars, and file contents that trigger the bug before changing many lines.

Comments

One comment per signed-in account. Comments are saved with this page’s URL.