To create an Express app, you will need to install the following npm packages:
1.
express
: This is the core Express framework that allows you to build web applications.
2.
body-parser
: This middleware is used to parse incoming request bodies in a middleware before your handlers, available under the
req.body
property.
Code:
bash
npm install body-parser
3.
morgan
: This is a HTTP request logger middleware for Node.js that logs requests to the console.
4.
cors
: This is a middleware that can be used to enable Cross-Origin Resource Sharing (CORS) with various options.
5.
dotenv
: This is a zero-dependency module that loads environment variables from a
.env
file into
process.env
.
6.
helmet
: This middleware helps secure your Express apps by setting various HTTP headers.
These are some commonly used npm packages when building an Express application. You can install them by running the provided
npm install
commands in your project directory.