Recent Posts

Getting Started With Node js

     

 GETTING STARTED WITH NODE JS

Node.js is an open-source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript and can be run within the Node.js runtime on OS X, Microsoft Windows, and Linux.

Installing Node:

  1. Download the required installer:
    1. Go to https://nodejs.org/en/
    2. Select the button to download the LTS build that is "Recommended for most users".
  2. Install Node by double-clicking on the downloaded file and following the installation prompts.

Following are some of the important features that make Node.js the first choice of software architects.


The easiest way to test that node is installed is to run the "version" command in your terminal/command prompt and check that a version string is returned:

> node -v

Example – Node.js HTTP Server


// include http module in the file
var http = require('http');
 
// create a server listening on 8087
http.createServer(function (req, res) {
    // write the response and send it to the client
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write('Node.js says hello!');
    res.end();
}).listen(8087);

Once you have created the file, you may run it using node program from the command line interface or terminal.

~$ node node-js-example.js





No comments

If you have any doubts, Please let me know