Node JS Tutorial - Nodemon

In this tutorial, we will learn about Nodemon, a utility that monitors for changes in your source code and automatically restarts your server. This makes it perfect for Node.js development.

Installing Nodemon

Installing Nodemon is a straightforward process. You can install it either globally or locally. Let's install Nodemon by running the following command in the command prompt:


npm install nodemon

This will install Nodemon on your system.

Running Nodemon

After installation, run the following command:


nodemon index.js

This will execute the index.js file using Nodemon. Switch to your browser, and you will see that the application is now running.

Automatic Restart with Nodemon

If you make any changes to the application, Nodemon will automatically re-run the application. Let's test this by making some changes to the index.js file.

Go to the index.js file and change the URL for the about page to "about-us". You will see that Nodemon automatically re-runs the index.js file.

Refresh the page in your browser and navigate to the about page. You will see that the old URL is no longer found. However, if you navigate to the new URL "/about-us", you will see the updated about us page.

This demonstrates how Nodemon can simplify your development process by automatically restarting your server whenever you make changes to your code.