Basics of NodeJS Part 1: Creating a Node Server

Mitusha Arya
Nov 2, 2020

What is Node JS Server?

A Node. js server makes your app available to serve HTTP requests. It provides interaction between users and your application. Creating and starting a server is easy with Node.js’s built-in HTTP module.

What is the difference between HTTP and HTTPS?

HTTP is used to launch a server and send requests.

HTTPS is used to launch an SSL server

Let’s get started.

Create a Node JS Project and then create an app.js file

Firstly, we import the HTTP module ad then create a server, where “req” is a request for incoming message and “res” is the response of the server.

Instead of ‘http’, you can also give path (by adding ./)of your local file and server.listen will keep on listening for the request.

Since we are running the file locally, we assign the local port 3000.

This is how we create a node server.

--

--