ExpressJS Installation

In this tutorial you will learn about the ExpressJS Installation and its application with practical example.

How to install ExpressJS?

To install ExpressJSfirst and foremost you are required to install node and npm (node package manger) in your system.
You can download node from the official website https://nodejs.org/en/ where you can get the latest version of node.
Once you download and install node you will get Node.js runtime as well as npmpackage manager in your system. After you are done installing node and npm you can check whether these are installed properly by running the following commands in your terminal:

For instance Output would look like:

1

2

Need of Npm

Node package manager is a public collection of packages of web apps, mobile apps, routers and many more. It provides youaccess to numerous of packages that you can easily download and use. You can download and install any package locally in your system and can also browse through the list of packages available on npm.

How to use npm?

There are two ways to install a package using npm: locally and globally. You choose which kind of installation to use based on how you want to use the package.
By default, NPM installs any dependency in the local mode.

Locally: If you are looking to install any framework or libraries and use them within a directory you can install a package locally.
To install a package locally, use the following command:

 

Globally: If you are looking to install a package and use it in your shell or in command line you can install it globally.

To install a package globally, use the following command:

 

Installing ExpressJS:

To install ExpressJS we need to provide package.json file, this file will always carry all the information of your module.
To create this file and install ExpressJS follow the following steps:

1) Open cmd/terminal and create a folder named myapp and cd(create directory) in it by using mkdir helloworld.

3

2) Now to create package.jason we need to use the following code:

It will ask you to fill some information; here is an example for you.

4

3) Package.json file has been created,now we need to install Express and add it to our package.jason file

Use the following command to install and save Express

5

In this tutorial we have learn about the ExpressJS Installation and its application with practical example. I hope you will like this tutorial.