Keep your Node.js scripts running with Forever and Nodemon

edit (18.06.2015): Nowdays I’m using PM2, and here’s my post that explains how to use PM2.


Nodemon is a utility that will monitor for any changes in your source and automatically restart your server.  Install with npm:

npm install -g nodemon

Forever is a simple CLI tool for ensuring that a given script runs continuously (i.e. forever). Install with npm:

npm install -g forever

Forever & Nodemon running together:

forever start nodemon --exitcrash app.js

edit (24.02.2015):

If you get an error like this:

error:   Cannot start forever
error:   script /home/nikola/nodemon does not exist.

Try to run nodemon with the full path:

forever start /usr/bin/nodemon --exitcrash app.js

You can find out the path to nodemon by executing:

which nodemon
Written by Nikola Brežnjak