How to download and install Node.js

To start out constructing your Node.js purposes, step one is putting in the node.js framework. The Node.js framework is offered for quite a lot of working methods, from Home windows to Ubuntu to OS X. As soon as the Node.js framework is put in, you can begin constructing your first Node.js purposes.

Node.js additionally has the power to include exterior performance or prolonged performance via the usage of customized modules. These modules should be put in individually. An instance of a module is the MongoDB module that means that you can work with MongoDB databases out of your Node.js utility.

On this tutorial, you’ll learn-

Easy methods to set up Node.js on Home windows

The primary steps in utilizing Node.js are putting in the Node.js libraries on the shopper system. To carry out the Node.js set up, comply with the steps under;

Step 1) go to website https://nodejs.org/en/download/ and obtain the mandatory binaries. In our instance, we’re going to obtain the 32-bit setup information for Node.js.

Step 2) Double-click the downloaded .msi file to begin the set up. Click on the Run button on the primary display to start the set up.

Step 3) On the following display, click on the “Subsequent” button to proceed with the set up

Step 4) On the following display Settle for the license settlement and click on the Subsequent button.

Step 5) On the following display, select the placement the place Node.js ought to be put in after which click on the Subsequent button.

1. First enter the file location for the Node.js set up. That is the place the Node.js information might be saved after set up.

2.Click on the Subsequent button to proceed with the set up.

Step 6) Settle for the default parts and click on the following button.

Step 7)On the following display, click on the Set up button to begin the set up.

Step 8) Click on the End button to finish the set up.

Putting in NPM (Node Bundle Supervisor) on Home windows

The opposite solution to set up Node.js on any shopper machine is to make use of a “package deal supervisor”.

On Home windows, the node package deal supervisor is called Chocolatey. It was designed to be a decentralized framework to shortly set up the apps and instruments you want.

To put in Node.js by way of Chocolatey, the next steps should be carried out.

Step 1) Chocolatey Set up: The Chocolatey web site (https://chocolatey.org/) has very clear directions on how this body ought to be put in.

  • The primary steps are to run the next command in command immediate home windows. This command is taken from the Chocolatey web site and is the usual command to put in Node.js via Chocolatey.
  • The next command is a PowerShell command that calls the distant PowerShell script on the Chocolatey web site. This command should be run in a PowerShell command window.
  • This PowerShell script does all of the work essential to obtain the mandatory parts and set up them accordingly.

@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object moist.webclient).DownloadString(‘https://chocolatey.org/set up.ps1’))” && SET PATH=%PATH%;%ALLUSERSPROFILE% chocolateybin

Step 2) The following step is to put in Node.js in your native machine utilizing the Chocolatey package deal supervisor. This may be finished by working the next command on the command immediate.

putting in cinst nodejs

If the set up is profitable, you’ll obtain the Node.js set up success message.

Observe:When you get an error like “C:ProgramDatachocolateyliblibreofficetoolschocolateyInstall.ps1”, manually create the folder within the path

Operating your first Hey world utility in Node.js

As soon as you have downloaded and put in Node.js in your pc, let’s strive displaying “Hey World” in an online browser.

Create the Node.js file with the file title firstprogram.js

var http = require('http');

http.createServer(operate (req, res) {
    res.writeHead(200, {'Content material-Sort': 'textual content/html'});
    res.finish('Hey World!');
}).pay attention(8080);
 

Code clarification:

  1. The essential performance of the “require” operate is that it reads a javascript file, executes the file, after which proceeds to return an object. Utilizing this object, one can use the assorted performance obtainable within the module referred to as by the require operate. So in our case, since we wish to use the performance of http and we’re utilizing the require(http) command.
  2. on this 2North Dakota line of code, we’re making a server utility that’s primarily based on a easy operate. This operate is known as each time a request is made to our server utility.
  3. When a request is acquired, we ask our operate to return a “Hey world” response to the shopper. The writeHead operate is used to ship header knowledge to the shopper and whereas the ultimate operate will shut the connection to the shopper.
  4. So we’re utilizing the server.pay attention operate to make our server utility pay attention for shopper requests on port 8080. You’ll be able to specify any obtainable port right here.

working the code

  1. Save the file in your pc: C:UsersYour Title firstprogram.js
  2. On the command immediate, navigate to the folder the place the file is saved. Enter the command Node firstprogram.js
  3. Now your pc works as a server! If somebody tries to entry your pc on port 8080, you may get a “Hey world!” message in return!
  4. Begin your Web browser and kind the tackle: http://localhost:8080
  5. Manufacturing


Abstract

  • We now have seen the set up of Node.js by way of the msi set up module that’s obtainable on the Node.js web site. This set up installs the mandatory modules which might be required to run a Node.js utility on the shopper.
  • Node.js will also be put in via a package deal supervisor. The package deal supervisor for Home windows is called Chocolatey. By working a couple of easy instructions on the command immediate, Chocolatey’s package deal supervisor robotically downloads the mandatory information after which installs them on the shopper machine.
  • A easy Node.js implementation is to create a server that listens on a specific port. When a request arrives on the server, the server robotically sends a ‘Hey World’ response to the shopper.

By admin

x
THE FUTURE - BENEFIT NEWS - DANA TECH - RALPH TECH - Tech News - BRING THE TECH - Tech Updates - News Update Viral - THE TRUTH - WORLD TODAY - WORLD UPDATES - NEWS UPDATES - NEWS FLASH - TRUTH NEWS - RANK NEWS - PREMIUM NEWS - FORUM NEWS - PROJECT NEWS - POST NEWS - WORLD NEWS - SPORT NEWS - INDICATOR NEWS - NEWS ROOM - HEADLINE NEWS - NEWS PLAZA