Deploy node.js on
Deploy node.js on

Instructions to create a simple node.js app called node_app and then upload and run it on

In order to use, you need to sign up and have your account approved. Do that now because approval does not happen immediately.


We will first get our node.js app working locally.

Download and install the latest node.js.

Change directory to where your code lives and then do:

$ mkdir node_app
$ cd node_app

Install the express package using the built in npm (node package manager).

$ npm install express

In your favorite editor, create a file called app.js and put the following in it:

var app = require('express').createServer();
app.get('/', function(req, res){
    res.send('The node.js app is working...');
app.listen(process.env.VCAP_APP_PORT || 8000);

Now you can run the app locally with:

$ node app.js

Test your app by going to: http://localhost:8000


You should now have a working local version of your app, lets get it working on

You will need to have ruby and rubygems installed. Then you want to install vmc:

$ sudo gem install vmc

Now lets start using vmc.

$ vmc target
$ vmc login
    (use the credentials from the approval email)
$ vmc passwd
    (optional: change password to something you will remember)

We need to add the details of our app before we push it, so in a file called package.json add:


Due to a bug, you will need to remove the symlink in the express module in order for a push to vmc to work.

$ rm node_modules/.bin/express

Now we need to push our app to

$ vmc push node_app
    (all the defaults are fine)

When doing $ vmc push node_app, my machine had issues with a couple installed gems: Invalid gemspec in [_gem_spec_]: invalid date format in specification: "2011-08-17 00:00:00.000000000Z"
I had to update the date format in my gem files, described here, in order for the push to work.

There you go. You now have a node.js app running on Enjoy…

December 14, 2011
338 words

cloud foundry node.js

Similar Posts

Will Stevens (swill)

Find me online...