Prepare your NodeJS Project Using Forever, Nodeunit and ExpressJS

Prior to creating Jenkins jobs and Capistrano recipes you should prepare NodeJS dependencies and scripts. This article does not provide in-depth details about NodeJS.

The assumptions are that nodeunit is used for unit testing, forever for process management, and ExpressJS for creating a web server.

Step 1: Create a package.json file:

NodeJS dependencies and utility scripts can be configured through the package.json file. Below is an example of such a file:


 "config": {

    "unsafe-perm": true


  "scripts": {

    "test": "node_modules/.bin/nodeunit  tests.js",

    "start": "./node_modules/forever/bin/foreverd start app.js",

    "stop": "./node_modules/forever/bin/foreverd stop app.js"


  "dependencies": {

    "express": "*",

    "forever": "*",

    "nodeunit": "^0.9.0"



More details can be found here: and here:

Step 2: Add some tests.js content (based on

exports.testSomething = function(test){


    test.ok(true, "this assertion should pass");



Step 3: Add a dummy app.js file (based on:

var express = require('express');

var app = express();

app.get('/', function(req, res){

  res.send('Hello World');

var server = app.listen(3000, function() {

    console.log('Listening on port %d', server.address().port);


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.