Lesson 27 / 30
Auto-Restart with nodemon
Restart your server on every file change with nodemon or Node's built-in --watch flag.
Installing & running
nodemon watches your files and restarts Node on every save — great during development.
npm install -D nodemon
npx nodemon server.jsNode's own --watch flag
Since Node 18, node --watch server.js does the same thing natively — no package needed for simple cases.
Quick check: What is the main benefit of nodemon (or node --watch) during development?
- It makes the app run faster in production
- It replaces the need for testing
- It bundles your code for production
- It restarts the server automatically on file changes
Answer
It restarts the server automatically on file changes — It removes the manual stop-and-restart cycle every time you edit code.