Setting Up For Epress
Setting Up For Epress
js and npm
1. Download Node.js:
2. Install Node.js:
● Run the installer and follow the setup instructions, accepting the default options.
● Node.js includes npm (Node Package Manager), which will be installed automatically.
3. Verify Installation:
Run the following commands to ensure Node.js and npm are installed:
node -v
npm -v
● You should see version numbers for both Node.js and npm.
Create a new directory for your Express project. You can do this via the terminal:
mkdir my-express-app
cd my-express-app
In your project directory, initialize a new Node.js project with the following command:
npm init -y
1. Install Express:
Use npm to install Express in your project:
Open index.js in your code editor and add the following code:
const express = require('express');
const app = express();
const port = 3000;
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
Update the package.json to use Nodemon for development. Add the following under the
"scripts" section:
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
}
1. Install Middleware:
You can add middleware like body-parser for parsing JSON, morgan for logging, etc. For
example, to install body-parser:
my-express-app/
├── index.js
├── package.json
├── routes/
│ └── index.js
├── controllers/
└── models/
● Deploy your app to a platform like Heroku, AWS, or Vercel following their specific
deployment guides.