The Web Developer Bootcamp 2024

Colt Steele

Back to Express Index Page


 

Express Js
nodemon

During the development process, every time we make changes to our controlling Js file, we have to restart our local server. There is a much better way. There is a package in the npm registry called nodemon.

According to the documentation, nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected. *note: nodemon will try to read "main" from package.json and without a nodemon.json, nodemon will monitor .js, .mjs, .coffee, .litcoffee, and .json by default.

nodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for node. To use nodemon, replace the word node on the command line when executing your script.


Install nodemon

The install for nodemon is very straight forward. It is an npm package so just open up your terminal of choice. If you want to install it globally, you would use:

  • npm i -g nodemon
and if you want to use it locally, navigate to your root project folder. If you already have express installed, you will already have a package.json file and a node_modules folder here. To install locally use:
  • npm i nodemon
Once installed, replace node with nodemon when you want to run a node app. The app will run as normal when using node but will restart the app every time it detects changes to your "parent" file. More info here.


Back to Top