Creating a web server in Node JS using Express

Setup the Node JS application

  1. Install Node JS from
  2. Create a directory and inside that directory give the command npm init.
  3. Install express by npm install express
  4. Create sub-directory src where we going to put all our code.
  5. Create a file app.js

Code app.js

const express = require(“express”);

const app = express();

app.get(“”, (req, res) => {

res.send(“Hello Express”);


app.listen(3000, () => {

console.log(“Server is up on port 3000.”);


Run the command node src/app.js

How to set up nodemon?

Nodemon allows us to re-run the server if any modification made on code level no need again restart the server by node src/app.js

  1. Install nodemon inside the project npm install nodemon
  2. Inside script of package.json add “dev”: “nodemon src/app.js”
  3. Run the project by using npm run dev