How-to Automate Restarting Node.js Server after Code Changes on Ubuntu Linux

December 24th, 2015 by thelinuxevangelist

Node.js Server Auto Restart SetUp

The Short Node.js Guide Shows You How-to Install the Node.js Modules to Automatic Restarting Server after that Code Changes are made.

The Node.js Modules for Server Auto Restarting used are:

  • forever: A simple CLI tool for ensuring that a given node script runs continuously.
  • node-dev: Restarts your app when files are modified
  • nodemon: Simple monitor script for use during development of a node.js app
  • supervisor: A supervisor program for running nodejs programs
How Auto Restart Node.js Server SetUp for Ubuntu Linux - Featured
  • Installing forever NPM Module:

    npm install -g forever

    Command line Usage: You can use forever to run scripts continuously (whether it is written in node.js or not)

    forever start app.js
  • Installing node-dev NPM Module:

    npm install -g node-dev

    Comman line Usage: just run node-dev as you should normally run node

    node-dev app.js
  • Installing nodemon NPM Module:

    npm install -g nodemon

    Command line Usage: nodemon wraps your application, so you can pass all the arguments you should normally pass to your app

    nodemon app.js
  • Installing supervisor NPM Module:

    npm install -g supervisor

    Command line Usage: Node supervisor can also be used to restart programs when a *.js file changes

    supervisor app.js

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , ,