Stop Using Nodemon for Development

In Node version 18.11+ you no longer need to use Nodemon for development!

What is Nodemon?

Nodemon is a command-line interface utility that helps us build Node applications by restarting the node application when it identifies file changes in the directory.

To normally run a Node.js app you would run:

node my-app.js

But anytime there were changes to your app, you would need to run this script again. Nodemon, while running would detect changes and restart your Node app auto-magically.

Why don't you need Nodemon?

Node.js version 18.11+ introduced "watch" mode, which lets you get all of the benefits of Nodemon without needing to install a dependency in your project.

Simply use the --watch flag when running a node command:

node --watch my-app.js

This will check for any changes in the file or its imports have changes and restart the server for you.

If you want to specify a folder to watch, you can be even more granular if needed (but I haven't found myself using it just yet), by using --watch-path. By watching a path you can only restart your server if there have been updates in the folders selected:

node --watch-path=./src my-app.js

Or multiple paths:

node --watch-path=./src --watch-path=./scripts my-app.js

Nodemon has been awesome over the years, and I think we can all see what inspired the addition to Node.

So major kudos to Remy Sharp, who has been keeping us sane for all the years up to this moment!

Don't know how to change versions?

If you don't know how to change versions or want to be able to change them for multiple projects, check out my article on Volta the Node Version Manager.


Follow me on Twitter or connect on LinkedIn.

🚨 Want to make friends and learn from peers? You can join our free web developer community here. 🎉

Node
Avatar for Niall Maher

Written by Niall Maher

Founder of Codú - The web developer community! I've worked in nearly every corner of technology businesses: Lead Developer, Software Architect, Product Manager, CTO, and now happily a Founder.

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.