# Auto-Restart with nodemon — Node.js

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

> Restart the server automatically whenever a file changes.

## Installing & running

`nodemon` watches your files and restarts Node on every save — great during development.

```bash
npm install -D nodemon
npx nodemon server.js
```

## Node's own --watch flag

Since Node 18, `node --watch server.js` does the same thing natively — no package needed for simple cases.

**Quiz:** What is the main benefit of nodemon (or node --watch) during development?

- [ ] It makes the app run faster in production
- [x] It restarts the server automatically on file changes
- [ ] It replaces the need for testing

*Answer:* It restarts the server automatically on file changes. It removes the manual stop-and-restart cycle every time you edit code.
