How to use node --inspect in Node.js

Debugging Node.js applications with console.log statements becomes inefficient for complex issues—you need breakpoints, variable inspection, and step-through execution. With over 12 years of Node.js experience since 2014 and as the creator of CoreUI, I’ve debugged countless backend systems in production environments. Node.js includes a built-in inspector that integrates with Chrome DevTools, providing a full debugging experience with breakpoints, call stacks, and performance profiling. This approach requires no additional tools and works with any Node.js application.

Start your Node.js application with the --inspect flag and connect Chrome DevTools to debug.

node --inspect app.js

Then open Chrome and navigate to chrome://inspect, click “inspect” under your Node.js process.

Alternatively, use --inspect-brk to pause execution on the first line:

node --inspect-brk app.js

In your code, you can add breakpoints programmatically:

const calculateTotal = (items) => {
  debugger // Execution will pause here when debugger is attached
  return items.reduce((sum, item) => sum + item.price, 0)
}

Best Practice Note

The --inspect flag starts a debugger server on port 9229 by default. Use --inspect=0.0.0.0:9229 to allow remote debugging. The --inspect-brk flag is useful for debugging code that runs immediately on startup. Chrome DevTools provides full source maps support, so you can debug TypeScript files directly. This is the same debugging workflow we use for CoreUI backend services—setting breakpoints in complex business logic, inspecting database queries, and profiling API performance bottlenecks.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author