Exercise 3: Using nodemon

In this exercise, we're going to introduce a Node module known as nodemon, which we will be using to run our web server. This makes it possible for the server to automatically reload when we make changes to it, therefore avoiding the tediousness of stopping the server and starting it over again manually whenever we make changes to our server:

  1. Go back to the Terminal and stop the server (press Ctrl + C), then run the following command.
  2. We will need to install this package globally (remember that you might need some administrative rights, so in Unix systems, you need to run the command as sudo):
npm install --global nodemon
  1. Once installation is complete, we can run with nodemon:
nodemon server.js

You should get something like this:

[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server running at: http://localhost:8000
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset