To create the server we need some packages
1) firstly install express package
npm i express –save
2) after that install http package
npm i http –save
Now, create the file server.js and put the below code
var http = require('http');
var express= require('express');
var app=express();
const httpServer = http.createServer(app);
httpServer.listen(4444,() => {
console.log('HTTP Server running on port 4444');
});
Note:- 4444 is a port number where Nodejs will run and you can create any port number according to you.
//run the file
node filename
node server.js
Output:- http://localhost:4444
HTTP Server running on port 4444
Note:- where require method is use to include the module.