The Wayback Machine - https://web.archive.org/web/20210719123137/https://www.geeksforgeeks.org/nodejs-automatic-restart-nodejs-server-with-nodemon/
Skip to content
Related Articles

Related Articles

Improve Article

Nodejs | Automatic restart NodeJs server with nodemon

  • Difficulty Level : Medium
  • Last Updated : 08 Apr, 2019

We generally type following command for starting NodeJs server:

node server.js

Image

In this case, if we make any changes to the project then we will have to restart the server by killing it using CTRL+C and then typing the same command again.

node server.js

It is a very hectic task for the development process.

Nodemon is a package for handling this restart process automatically when changes occur in the project file.



Installing nodemon: nodemon should be installed globally in our system:

Windows system: npm i nodemon -g
Linux system: sudo npm i nodemon -g 

Image

Now, let’s check that nodemon has been installed properly to the system by typing the following command in terminal or command prompt:

nodemon -v

It will show the version of nodemon as shown in the below screenshot.

Image

Starting node server with nodemon:

nodemon [Your node application]

Image

Now, when we make changes to our nodejs application, the server automatically restarts by nodemon as shown in the below screenshot.

Image

In this way with nodemon server automatically restarts.

My Personal Notes arrow_drop_up
Recommended Articles
Page :