Nearby lessons

7 of 21

🔄 Node.js – Nodemon

📌 What is Nodemon?

What is Nodemon?

Nodemon is a tool that supports hot reload in Node.js backend applications. It means you don't need to close and restart your application for changes to take effect. The server automatically restarts and applies changes when a file is modified.

⚙️ Nodemon Installation

Install Nodemon globally using npm:
npm i nodemon -g

❌ If Nodemon is not running

  • Open Windows PowerShell with Run as Administrator
  • Run get-ExecutionPolicy
  • Run Set-ExecutionPolicy Unrestricted
  • Run get-ExecutionPolicy again to verify

🔁 Alternative to Nodemon

Node.js 18.11+ introduces a built-in --watch feature for hot reloading.
You can use the following command instead of Nodemon:
node --watch fileName

✅ Summary

Nodemon simplifies development by automatically restarting the server on file changes. In Node.js 18.11 and later, you can use the built-in --watch flag as an alternative to achieve hot reload.
Node.js Environment
RUNTIME ACTIVE
console.log("Nodemon simulation...");
console.log("In a real environment, saving this file would restart the process.");

let count = 0;
setInterval(() => {
  console.log("Tick:", ++count);
}, 1000);
Terminal Output
Live Output Preview

🧠 Test Your Knowledge

4 Questions

Progress: 0 / 4
Keep Going!Synchronous vs Asynchronous in Node.js