Forever with NPM

Forever NPM module

So you've heard of the Forever NPM module right? Its a very simple node module that makes sure your NodeJS script runs.....forever! Check it out here.

Normal use case

Most of you will be familiar with the notion of starting your NodeJS applications via;

$node start app.js

and by extension using Forever to start your application;

$forever start app.js
Starting app using NPM

Those of you who are more experienced in the NodeJS world may prefer starting your NodeJS applications using package.json to configure your entry point and NPM start from your application directory;

$npm start

So to use Forever to start up your application is this manner, you can do;

$forever start -c "npm start" ./

Of course this command needs to be run from your application directory, or just specify it at the end. Success! Your application has been started in the background, and will run forever. Happy days!