Published on: 10/8/20 3:42 AM
Category:Node Tags: nodemonIn 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
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 🙂
These are in fact enormous ideas in about blogging. You have touched some good points here. Any way keep up wrinting. Thomasin Lay Lief