Node – Express JS Server

node_js_thumb

Create and express-js server. Express Js is a framework that helps building apps more easier using the node js.

Steps for using Express:

Create folder: my-express-server

create file : server.js

npm init // initialize node in the folder, entry point server.js

now package.json file will be created inside the folder

Installing Expess

npm install express //node modules will be added

Add following code inside server.js

const express = require("express");
const app = express();

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

app.listen(3000, function(){
    console.log("server started at port 3000");
});

Run the server: node server.js

// server gets started and check at http://localhost:3000/

About the Author: smartcoder

You might like

Leave a Reply

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