Setup Express and run first application in Node.js

In this post we will take a step by step look in setting up Express and creating first application. I assume that you have already installed Node. If not then go ahead and install from here

Once node.js is successfully installed, you can install Express framework by running npm install express on command prompt.

clip_image001

After installing express, I will recommend to create a new folder and change directory to newly created folder. I have created a folder expressjs and going to create a site named mysite using express framework. To create site run command express mysite . mysite is name of the site.

image

On successful execution of above command you will get suggestion as below that several files has been created.

clip_image003

Next to install dependency. To install that navigate to site directory. You can navigate to site directory using cd mysite. In mysite directory

clip_image004

It will install all dependency in mysite directory.

clip_image005

After successful installation of dependency you should get npm info ok message as shown in above figure. Now you can run created website by express using node.

clip_image006

In browser navigate to server on port 3000 and you will get basic site created using express up and running.

clip_image007

This is how you can set up express to create sites running on node.js. In further posts we will look into routing, app.js, routing path, http verbs. I hope you like this post. Thanks for reading.

5 responses to “Setup Express and run first application in Node.js”

  1. […] learning on express Routing with you. If you are starting with Express feel free to have a look on Setup Express and run first application in Node.js […]

  2. […] If you are just starting with Express and nee help getting it set up, check out my other tutorial on how to set up Express and run your first application in Node.js . […]

  3. Ashutosh Pathak

    I have Win 7 Professional and encountered with a problem on installing Express Framework, now below command solved my problem. hence giving here to help others.

    npm install -g express-generator@3

  4. […] If you are just starting with Express and nee help getting it set up, check out my other tutorial on how to set up Express and run your first application in Node.js . […]

  5. the last command: node app.js –> does not work?

Leave a comment

Create a website or blog at WordPress.com