Email: info@zenconix.com

Use nodemon in Node app

Published on: 10/8/20 3:42 AM

Category:Node Tags:

In last couple of post, we are looking for how to work with Express Js.
If you have not yet seen the post, please take a look at the posts below.

http://zenconix.com/create-node-app-with-express-js/

http://zenconix.com/create-routes-in-express-js/

When we change anything in our code, we need to restart node server by command in terminal as node app.js

This is quite hectic, we should have something which will restart the application for us when we do the changes.


There is one npm package, called nodemon – which automatically restart the server for us.

You can find the detailed information about nodemon on their official website

https://nodemon.io/

and It’s npm package URL – https://www.npmjs.com/package/nodemon

Let’s include this in our project, to add this go to terminal and enter command as below

npm install nodemon --save-dev

As we need this for our development environment only, we need to add it as developer dependency , to do that just add --save-dev at the end while installation.

After installation, go to package.json file and add below configuration in script section

"start": "nodemon app.js"

So our script section will look something like below.

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon app.js"
  }

Now go to terminal and enter command as npm start, it will start our node server using nodemon and if you change in any file, you don’t need to start the application again and again as before, nodemon will take care of this for us.

Happy Coding 🙂


2 thoughts on "Use nodemon in Node app"

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Use template to Express – Pug

In this post, we are going to take a look on how to use template to our express js application, in this post we are going to focus on using Pug template to our application. If you have not yet read previous blog posts on Node, please take a look on it as this post […]

Create routes in Express Js

In last post, we have seen how to create express js application in node. http://zenconix.com/create-node-app-with-express-js/ In this post, we are going to take a look on how to create routes in express application. To add routes in our application, we need to add middlewares, detailed information about middlewares in express js is available at the […]

Create Node app with Express JS

In this post, we are going to take a look on how to create Node application with Express JS. You need to install node and npm in your machine. Node can be installed from https://nodejs.org/en/download/ npm can be installed from https://www.npmjs.com/get-npm To create application, open terminal and enter command npm init It will ask you […]