Express JS Installation

As we all know that the Express js is a framework for the Node JS. So first, you need to install Node JS.

Download Node JS from Here


Create your first Node app using Express JS

After installing the Node JS now create a folder on your desktop and name it as you wish. This is our app folder.

Then inside the app folder initialize NPM by running npm init command.

After initializing the npm, to install express run the below command –

npm install express --save

Now create the index.js file on your app folder.

index.js

// Import Express
const express = require('express');
// app is an instance of express.
const app = express();
// Set route
app.get('/', (request, response) => {
    response.send('Hello Express.')
});
// Run app on port 3000
app.listen(3000, () => console.log('Your app listening on port 3000'));

Now run the index.js file by running node index command on your terminal. (Make sure that your app folder is selected on your terminal)

Now open http://localhost:3000 on your browser

Browser Output
Hello Express.

Next is – Express JS Routing

Leave a Reply

Your email address will not be published. Required fields are marked *