How to Install Express.js?

To install express.js using npm, run the following command.

npm install express

To install it globally, run the above command with -g option. g for global.

npm install -g express
Node.js NPM install -g express

Once express.js is installed, you can import express.js into your node project using require statement.

var express = require('express')

Now, express variable holds the reference to the express.js package.

If you do not install express.js prior to using it in your Node.js project, you will get an error as below:

Node.js Cannot find module 'express'