Available for hire
How to: Install Node Js and Roll Out Your First Project

So after NodeKnockout I have to say I learnt a lot about the simplicity that comes with developing a nodeJs app! A few people have asked me about how easy it is to roll out their own app, and I’ve walked a few people though it, and finally decided it warranted a blog post! You’ll be walked through how to set up:

Quick Note

I’m doing this on a mac, but it should be the same on any posix system (linux, bsd, etc) (sorry windows, but if you want to be a serious developer, and .Net isn’t doing it for you, then change your OS) So lets get this started!

Install NodeJS

Visit the NodeJS website and download the latest node package. It’ll come in tar.gz format. At the time of writing this, its node-v0.2.0.tar.gz. So I’ll pull it down, and install it! On the console do:

1
2
3
4
5
6
wget http://nodejs.org/dist/node-v0.2.0.tar.gz
tar xvf node-v0.2.0.tar.gz
cd node-v0.2.0
./configure
make
sudo make install

The sudo is required as node installs /usr/local/lib/ Once thats done, check to make sure you have it installed

1
node --version => 0.2.0

Install NPM

Visit the NPM site. There is a link to the github repo that has some extra info not on the site. I recommend visiting it and reading the readme.. After you’ve done that, to install:

1
curl http://npmjs.org/install.sh | sudo sh

And then check if its installed

1
npm --version => 0.1.27-11

You might have a later version, again this was the latest at time of writing.

Express

Express is a sinatra like framework that wraps nodejs. It looks pretty sexy! It uses Jade by default, which is a HAML like templating language. Very sexy indeed.

1
2
sudo npm install express
sudo npm install jade

Rolling out a new nodejs app!

Express has a few generators, which makes life easier for all involved.

1
express my_new_project

Go through the project and have a look at the directories/files. The important one there is the app.js file. This file is used to run your new project! To run your node server run

1
node app.js

You can then point the browser at http://localhost:3000 and bingo!

Where to find packages?

There is a good list of hosted Addons & Modules. Or just a bit of googling will come up with a few extras. In further articles I’ll write a little bit more about how to modify the app, add extra actions, etc.