Monday, 5 August 2013

NodeJS application Deployment

NPM Logo
NPM Logo
Recently I prepare to deploy a NodeJS application for server side application. There are some dependency and prerequisite software to be installed, like mongoose lib, ExpressJS lib, and other lib in NodeJS environment.

To make this deployment easy, NodeJS come with NPM, which can install all the needed library from a single file called package.json . We just list all the dependency needed by the application, in development and in production environment. This makes life easier for programmer like us.

Here are some example of the package.json :

{
  "name": "AwsomeFaqSite",
  "version": "0.0.0",
  "dependencies": {
    "express": "~3.1.0",
    "path": "~0.4.9",
    "mongoose": "~3.5.5",
    "passport": "~0.1.17",
    "passport-local": "~0.1.6",
    "connect-memcached": "~0.0.3",
    "helenus": "*",
    "node-uuid": "*"
   },
  "devDependencies": {
    "karma": "~0.8.6",
    "grunt": "~0.4.1",
    "grunt-contrib-copy": "~0.4.0",
    "grunt-contrib-concat": "~0.1.3",
    "grunt-contrib-coffee": "~0.6.4",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-compass": "~0.1.3",
    "grunt-contrib-jshint": "~0.3.0",
    "grunt-contrib-cssmin": "~0.5.0",
    "grunt-contrib-connect": "~0.2.0",
    "grunt-contrib-clean": "~0.4.0",
    "grunt-contrib-htmlmin": "~0.1.1",
    "grunt-contrib-imagemin": "~0.1.2",
    "grunt-contrib-livereload": "~0.1.2",
    "grunt-bower-requirejs": "~0.4.1",
    "grunt-usemin": "~0.1.10",
    "grunt-regarde": "~0.1.1",
    "grunt-rev": "~0.1.0",
    "grunt-karma": "~0.3.0",
    "grunt-open": "~0.2.0",
    "grunt-targethtml": "~0.2.4",
    "matchdep": "~0.1.1",
    "grunt-google-cdn": "~0.1.1",
    "grunt-ngmin": "~0.0.2"
  },
  "engines": {
    "node": ">=0.8.0"
  }
}


We define the package name of our application which is AwesomeFaqSite , version, and the dependencies of the application. Then we just install all in the new server with just running

  npm install

The npm will look for package.json for default, and install all the application defined in the package.json .
All the required lib will be installed under the same directory level under node_modules directory.

From my experience with other programming language, this npm method is the easy and fastest way to deploy new development or production environment.

Bravo NodeJS community and the Npm developer. in Python world there are pip install and pyenv which look like npm method.

Hope this help someone like you who read this post.

Leave a comment and let me notice your visit.

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More