When writing a Node.js application, it's frustrating to have to start and stop the application whenever changes are made. To allow us to develop more efficiently, we need something that monitors our Node.js application directory and restarts the application whenever changes are made.
This is where
nodemon comes in.
nodemon doesn't require any changes to your application's source code and can be used instead of the node command to start an application.
To install nodemon, simply use npm:
>sudo npm install -g nodemon ... firstname.lastname@example.org /usr/local/share/npm/lib/node_modules/nodemon
You can then start your application using the
nodemon command instead of the
node command and it will be automatically restarted when changes to the source code are detected.
>nodemon app.js 24 Jun 20:15:27 - [nodemon] v0.7.8 24 Jun 20:15:27 - [nodemon] to restart at any time, enter `rs` 24 Jun 20:15:27 - [nodemon] watching: ~/dev/MyApp 24 Jun 20:15:27 - [nodemon] starting `node app.js` Express server listening on port 3000 .. 24 Jun 20:15:50 - [nodemon] restarting due to changes...