Use nodemon to restart node application automatically on code change
Mar 25, 2016

We usually need to rerun node server.js when debugging Node.js project, which is painful and inefficient. Actually we can use nodemon to automatically restart node by monitoring the files change.

Installation

npm install -g nodemon

Usage

The simplest way is to replace node with nodemon to start your Node.js application. nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.

nodemon server.js

Advanced

For more advanced usage like: monitoring multiple directories, running non-node scripts..., you may reference: https://github.com/remy/nodemon.

Categories

Node.js