Complete 2024 Web Development Bootcamp

Dr. Angela Yu

Back to Express Index


Nodemon

When writing server code, it is important to remember that if your server is running, and you make changes to your server code, YOU MUST STOP THE SERVER (ctrl + c) and RESTART THE SERVER (node index.js). This can become problematic during the development process when you may have to stop, and restart the server, many times.

Some very brilliant programmers found that this constantly stopping and restarting the server during the development phase, was very annoying. So they developed an npm package called nodemon, which will automatically restart your server for you when it detects any file changes in the directory.

nodemon is a npm package, so it needs to be installed. It is also recommended that you install it with a "global" scale, using the -g option:

  • npm i -g nodemon

Once nodemon is installed, when you run your file from the terminal, you just replace node fileName.js with nodemon fileName.js, and you're all set. Once the server is running under nodemon, every time you make changes to your file, nodemon will automatically stop and restart the server for you.


Back to Top