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
You can easily install the express application in your system with the following simple steps –
Install Node.js
First of all, Install the latest LTE Version of Node.js from the official website nodejs.org.
Install Express Js
After that, Go to the root directory in your system where you want to install the express js.
Run the following command to create the Express app –
npx express-generator --view=ejs nodeapp
Where –
- ejs is the template engine
- nodeapp is the root folder of the express app
After successfully run the above command, you will get the express app wit the following command.
create : myapp/ create : myapp/public/ create : myapp/public/javascripts/ create : myapp/public/images/ create : myapp/public/stylesheets/ create : myapp/public/stylesheets/style.css create : myapp/routes/ create : myapp/routes/index.js create : myapp/routes/users.js create : myapp/views/ create : myapp/views/error.ejs create : myapp/views/index.ejs create : myapp/app.js create : myapp/package.json create : myapp/bin/ create : myapp/bin/www
Install npm Dependencies
Go to the nodeapp root directory –
cd nodeapp
Now You have to install the npm dependencies by running the following command
npm install
Run Express Js App
After that, You have to start the node development server using the following command to run the express app
DEBUG=nodeapp:* npm start
After getting started on 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.
Thanks for reading this tutorial…
A good tutorial, be blessed