# My first 'Hello World' Application in Node.js

In 
Published 2022-12-03

This tutorial explains to you how to create a simple Hello World example in Node.js. This example is something you have to do as your first Nodejs application.

In order to create a "Hello World" example in Node.js you have to test if Node.js is installed:

If the node.js is not installed you have to Install Node.js on your machine.

After that you have to write the code. For my example I created the following simple web server:

var http = require("http");
 
http.createServer(function (request, response) {
 
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});
    
   // Send the response body as "Hello World"
   response.write('Hello World !\n');
   response.write('This is my first application in Node.js');
   response.end();
}).listen(8082);
 
// The Command Line will print the message
// When/ where you run the HelloWorldNodeJs.js file
console.log('Server running at http://localhost:8082/');

Save the code in a file named "HelloWorldNodeJs.js" (but this is just for my example) and run it :

You can see that you can log some information on the console as well.

When you open your browser at http://localhost:8082 you will see: