Express is a backend framework which is a server side technology that connects to the database. Basically, a browser or a frontend framework will make a request to the backend framework to perform some action which might be reflected in the database.
- Light, Fast, Free
- Convenient way to build NodeJS app
- Community-driven, a lot of helper libraries
- Download node from NodeJS
- Choose the recommended version
- Run the wizard
- Use node -v on command prompt to ensure that the installation has been done completely
- Create a folder in your preferred directory
- Open the folder in VSCode
- Open terminal
- Type the following command:
npm init -y
npm install express --save
npm install nodemon --save-dev
Create a new file named index.js
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!');
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
})
Go to package.json and add a new script
"start": "nodemon index.js"
Type npm run start
in the terminal to run your app