How to create a server in node.js
Mar 19, 2021
If you read my previous tutorial How to make your first program in Node.js this one is quite easy.
Node.js allows us to easely create a HTTP server. To demonstrate it we will create a web page that show a simple message “Hello world!”
The first step is to create a Notepad++ file and type the following code:
Then save your file as server.js.
The next step is to open Node.js command prompt, and after we change the directory, we will type the following command:
node server.js
The open your browser and go to the localhost:
The output must look like the image below: