Getting started quickly with Node.js and Express

expressI was recently asked to look into building a sample application based on Node.js – more on that in another post. I only had a couple of days to figure this out and I am sure I didn’t do everything correctly but in the end it worked out great. I basically followed the instructions in this article, however, the best part of the article is the Express command to create the sample application code, ie. the famous “Hello World” example. This for me was a great launch pad in getting started. I was able to investigate the file structure and see how a Node.js + Express is constructed. So the first thing is to get up and running with Node.js, I installed it from the Install button on the Node.js site.

So what was the command?

express --sessions mynewapp

This resulted in the directory structure with all of the basic files configured to run.

node-dir

The next command is to install the dependencies:

npm install

This installs all of the dependencies identified in package.json and a new directory should be generated:

node-dir-install

The last step is to simply run the application server locally:

D:nodesportsapp>node app
Express server listening on port 3000

You can then launch your application with the following URL: http://localhost:3000/

3 thoughts on “Getting started quickly with Node.js and Express

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s