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](https://www.tutorialkart.com/wp-content/uploads/2019/06/node-npm-install-g-express.png)
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:
ADVERTISEMENT
![Node.js Cannot find module 'express'](https://www.tutorialkart.com/wp-content/uploads/2019/06/nodejs-cannot-find-module-express.png)