Why Do We Use npm install --save-dev nodemon in Node.js?
If you’re starting with Node.js, one command appears very early in tutorials and projects:
npm install --save-dev nodemonAt first glance, it may seem like just another package installation.
But once you understand what nodemon does, it quickly becomes one of those tools you don’t want to develop without.
The Problem Without Nodemon
Imagine you start your Node.js application:
node server.jsOutput:
Server running...Now you update your code:
Before:
console.log("Hello");After:
console.log("Hello Updated");Nothing changes automatically.
You must manually restart the server every time:
CTRL + C
node server.jsIf you’re making lots of small changes, repeating this becomes slow and annoying.
What Nodemon Does
Nodemon watches your files and automatically restarts your server whenever changes are detected.
Install it:
npm install --save-dev nodemonAdd a script to package.json:
{
"scripts": {
"dev": "nodemon server.js"
}
}Run:
npm run devOutput:
[nodemon] starting `node server.js`
Server running...Now edit your code:
console.log("updated");Save the file.
Get Thisharika Rangani’s stories in your inbox
Join Medium for free to get updates from this writer.
Nodemon automatically does:
[nodemon] restarting...No manual restart required.
Why Use --save-dev?
You’ll often see this installation command:
npm install --save-dev nodemonThe --save-dev flag means:
Install this package only for development.
That’s because nodemon is not needed in production.
After installation, package.json updates like this:
{
"devDependencies": {
"nodemon": "^3.x"
}
}Example project:
{
"dependencies": {
"express": "^5.x"
},
"devDependencies": {
"nodemon": "^3.x"
}
}Difference:
- dependencies : Required for the application to run
- devDependencies: Required only during development
Typical Node.js Setup
Install runtime dependency:
npm install expressInstall development dependency:
npm install --save-dev nodemonpackage.json
{
"scripts": {
"dev": "nodemon server.js",
"start": "node server.js"
}
}Use:
npm run dev→ During development
Use:
npm start→ In production
Final Thoughts
Nodemon doesn’t make your application faster.
It makes you faster.
By automatically restarting your server after changes, it removes repetitive manual work and creates a smoother development experience.
That’s why nodemon is one of the first tools many Node.js developers install.
Small tool. Big productivity boost.










