How to setup a basic express server?
Step 1:
Write npm init command in your terminal.
Step 2:
Install Express.js by running the following command in your terminal.
npm i express
Step 3:
Create a new file called app.js, this is going to be the entry point of our application. Add the following codes in app.js file.
const express = require( "express" );
const app = express( );
const PORT = 4000;
app.listen( PORT, ( ) => {
console.log(`Server is working on ${PORT}`);
}
);
Step 4:
Run the server by running node app.js command in your terminal.