Create your first Web Application using expressjs

In this tutorial, we will learn how to create your first Web Application using Express Framework.

Prerequisites

  • Node.js

Before creating Web Application using Node.js Framework i.e. ExpressJS, we need to install Node.js in our system.We can download and install these software by following link :-

Node.Js :- Install Node.Js

Once you installed software in your system, you can check its installed or not by following command :-

Check Node.Js installation

Installing ExpressJS

Once NodeJs is installed in our system.We can install Express through NPM(Node Package Manager).
Express can be installed globally and locally in our system.
If you want to installed Express globally then run the following command :-

This will install globally Express in your system.So you can use Express anywhere in your system.If you want to install locally then run the following command :-

This will install express locally in your project folder.So you can use Express inside your Project.

Check Express installation

NOTE :-Try to install Express globally to use anywhere.

Express application generator

We can install the application generator tool, express, to quickly create a application skeleton.
command to install express application generator tool :-

Display the command options with the -h option:-

Creating Express App using Express generator tool

Create the Express Web application using express generator tool.The following command creates an Express app named myapp in the current working directory.

This command will create the myapp express project in your current working directory.

Output in Terminal

express-demo-app

Install dependencies

Check installed dependencies

We can check the installed dependencies using following command :-

Run the app (on MacOS or Linux):-

Run the app on Windows:-

Access the app in browser :-

Generated app directory structure

Conclusion

In this article, we learned about how to create Express Web application from scratch. In the process, we also learned how to install express through npm and how to build application using express generator tool.Please give your valuable feedback regarding this article and please post comment if you any queries regarding this article.

About Ritesh Kumar

I am Full Stack Developer and Blogger from Bangalore, India.

Leave a Reply

Your email address will not be published. Required fields are marked *