Introduction

Today we’re going to be setting up a Node.js and Express environment on your Windows machine. Node.js is an awesome JavaScript platform for creating web applications. It is built on top of the Google Chrome V8 javascript runtime engine. We will use Node in conjunction with the application framework Express, to build a test server that returns a basic html page.

This tutorial is for absolute beginners, so if you have Node and Express installed already, you probably won’t find much help in this tutorial.

Getting Started

Our first task is installing Node, we can go to nodejs.org. Click the install button and it will automatically download an installer. Run the installer and it will walk you through the steps of the install. Once you are finished, you should have a node directory within your program files directory.

You can now test to see if Node is installed on your system by opening up your cmd prompt, and typing:

If Node is installed it will return the version of Node you are currently using.

Installing Express

Next, we want to install Express. Express is an application framework for Node that employs common MVC architecture. We can install express with the node package manager, or npm.

The -g flag specifies that we want Express installed globally. If you do not wish to install Express globally, you need to create a directory for your project before you install Express with npm. After Express is installed globally we can create some directories for our project. We’re going to create a Development and a Node directory in the command prompt:

Let’s make Node our working directory:

Great, now we’re in our Node directory. To create a new Express project, we can just type:

Now Express will create the application tree under the directory name express_site. At the end of the process list you will see the line:

We must install Express’ dependencies by typing that command into our command prompt:

You will now see the dependency packages installing, this may take a while so be patient. Once these packages are installed you will be ready to run your new Node & Express application so make sure your working directory is the same as your application’s root directory. Once you’re sure you’re in the application directory you can use the following command to start your development server:

You will be returned a string that says something along the lines of “Express server listening on port 3000″. Open up your browser and navigate to localhost:3000 to see your newly created web application.

express

It’s that simple, for more documentation visit Express.