NodeJS Installation and Hello World Program

Node.js is a programming environment based coding on the Javascript programming language with input and output data server is object-oriented and was developed in the V8 javascript engine. Node.js is highly efficient and scaleable, it is ideal for real-time applications, as Node.js is designed for situations in which you are expecting a lot of traffic

First of all download and install Node.js from the link above, simply pressed next to the windows and change the installation path if you wish, now you have installed, we only need to write some code.

node-js-setup

Here we go, let’s write our first program, but in Specifically a small and basic web server, we will open a text editor and write the following code:[/vc_column_text][vc_column_text]

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Helo World!');
}).listen(8081);
console.log('Server running at http://192.168.1.1:8081/');

Now we keep it where we want but as a file javascript keep it as such ADDING the .js extension, I will name it heloworld.js.
We open a terminal:

Windows:
Windows + R -> CMD

Linux:
Alt + F2 -> gnome-terminal

Type:
node holamundo.js[/vc_column_text][vc_column_text]and now we get to a web browser and type in the address bar the following address:
http://192.168.1.1:8081/

Now we will see the message Hello World! in our Web browser. If we want to give something more to remember you can edit presentation the writehead lines and response.end and include any HTML code, we will do and change those lines by these

response.writeHead(200, {'Content-Type': 'text/html'});
response.end('<html><head></head><body bgcolor="#303030 "><h1 style="text-align:center;color:#FFFFFF;">Helo World!')

if all goes well we will see the website we insert in the response.end line and will look like:.

 

NodeJS being used for the development of mobile applications for CloudComputing as big as Microsoft has its Azure node on eBay, yahoo LinkedIN platform and are paving the way for this new technology

Leave a Comment

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

Scroll to Top