How to Install Express Application Using Express Generator Tool

Install Express Application: This tutorial will help you to create a basic structure of Express js. If you are going to develop web applications using express js, you should create a basic structure of express. So that you can easily develop your web application. Even you will get a basic demo of routing, static files & views folder. On the basis of these demos, you will be able to create other folders, files & coding scripts according to your project requirement.

Express Generator Tool

Express Generator Tool provides an environment to quickly create a basic structure of express. You can read more about it  through the official website expressjs.com

Before installing the express app, Node.js & NPM  must be already installed on your computer or laptop.

How to Install Express Application

Before Installing Express Application, Configure the following points –

  • First of all, Make Sure that Node.js was already installed on your computer/laptop
  • Create a Project Folder like myproject in D drive. You can create it in another drive

1. Install Express Generator

First of all, open the command terminator and go to myproject folder directory using the command –

D:\> cd myproject

 

After that, Install the Express  generator using the following command line

D:\myproject> npm install -g express-generator

2. Install Express Application

Run the following command to install the express application.

npx express --view=ejs nodeapp

 

In the above command, ejs is a template engine of the express and nodeapp is the root folder of the created express.

After running the above command, you will get the following instructions

PS D:\myproject> npx express --view=ejs nodeapp

   create : nodeapp\
   create : nodeapp\public\
   create : nodeapp\public\javascripts\
   create : nodeapp\public\images\
   create : nodeapp\public\stylesheets\
   create : nodeapp\public\stylesheets\style.css
   create : nodeapp\routes\
   create : nodeapp\routes\index.js
   create : nodeapp\routes\users.js
   create : nodeapp\views\
   create : nodeapp\views\error.ejs
   create : nodeapp\views\index.ejs
   create : nodeapp\app.js
   create : nodeapp\package.json
   create : nodeapp\bin\
   create : nodeapp\bin\www

   change directory:
     > cd nodeapp

   install dependencies:
     > npm install

   run the app:
     > SET DEBUG=nodeapp:* & npm start

3. Install Dependencies

Go to the created root folder myapp  by running the following command

PS D:\myproject>cd nodeapp

 

Install dependencies  using the following command

PS D:\myproject>nodeapp >npm install

 

5. Know about Express Application Structure

After configuring the above steps, you will get the following folder structure of Express Application. So, Before start coding with it, you should know about its necessary files –

install express application

 

4. Run Express Application

First, run the following command to start Node.js Server

npm start

After getting started the server, Run your Express App by entering the following Port in your browser.

http://localhost:3000/

 

My Suggestion

Dear Developer, I hope you have learned how to install the express application using the express-generator. Now, you can easily develop projects using express. So, continue to visit my website, I will share more Node.js & express.js tutorials for you.

If you have any questions & suggestions related to this article or the web technology coding field, You should ask me through the below comment box.

Thanks for reading this tutorial…

Categories Node.js

Leave a Comment