How to install express in node js

To start developing with Express we are required to install node js to run the server.

Then using this command install express by creating a new directory:-

mkdir myapp
cd myapp
npm init
npm install express --save

Then create index.js write below codes:-

var express = require('express');
var app = express();

app.get('/', function(req, res){
   res.send("Hello Techlifediary!");
});

app.listen(3000);

and then install nodemon by below command:-

npm i nodemon

nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.

nodemon index.js

Now the server is started and when you hit localhost:3000 in the browser you will see Hello Techlifediary in the browser

How to Recover loss or deleted Data?

Leave a Reply

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