Press "Enter" to skip to content

How to install express in node js

0

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?