# Debugging Node — Node.js

Source: https://www.geekswithgeeks.com/en/nodejs/node-debugging

> console methods and the built-in inspector.

## Beyond console.log

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

```javascript
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.

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

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