Nodemon - Helping hands for Node JS Developers


Nodemon is a tool that helps Node js developers by automatically restarting the server when it detects any changes in the files of your Node js application Directory.



Considering "app.js" is the main js file (the entry point) in your Node Project, You do not need to manually run the "node app.js" in the terminal every time you make any changes to run your application. It saves a lot of time.

But, don't worry you don't have to make any additional changes to your code. nodemon is just a wrapper to our node command.


Installation of Nodemon

npm install -g nodemon

-g is to install nodemon globally.


But, one thing to keep in mind that nodemon is not a package that can help you in production build, this is something to help the node js developers in their development.

So, Its always better to install such dependencies as your dev-dependency because you are not going to use them in production.

npm install --save-dev nodemon

The above command will install nodemon as locally and will not be available outside your project directory.




Ways to run the locally installed / dev dependencies Packages

1. Using the npm Script
2. Using the npx command
3. You have to run the npm command from the location of package installed. i.e the bin directory of node modules. [Not recommended]


As we have installed nodemon as a dev dependency, Let's see the options we can run the locally installed package.

Using the npm Script

  • Add the script in the scripts object of the package.json file.
  • In the terminal, run the command - npm run <your script name>






Terminal:




Using the npx command








I hope you liked this post 😊. Please Share.