Getting up and running with Express.

So if you followed my mongo article then you have mongo setup and ready to go. The rest of this article will assume that you have node and npm already installed. If not a simple google search should show you how.

Step 1: Install Express

This can be done with

sudo npm install -g express  

The -g flag installs assets globally for all projects as opposed to per project.

So we installed express globally. Now we have to generate some project scaffolding from it. So here it is:

express -c stylus  

Now that you have generated a basic express app you have to install the dependencies. This is done with:

sudo npm install  

The sudo may not be required for all installations but I use it anyway because sometimes I get access errors from the file system otherwise.

Now from your app root you can start the app simply by typing: node app . If you browse to localhost:3000 in your browser you should see express running! Congrats!

In the next article we will take a look at using mongo to store data.