How do you handle errors in Node.js?

Error handling in Node.js can be done using try-catch blocks for synchronous code and error-first callbacks for asynchronous code. In Express, you can use middleware to catch errors. Example:

app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});