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-ExecutionPolicyagain to verify
🔁 Alternative to Nodemon
Node.js 18.11+ introduces a built-in
You can use the following command instead of Nodemon:
--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
🧠 Test Your Knowledge
4 QuestionsProgress: 0 / 4
Keep Going!Synchronous vs Asynchronous in Node.js