in

WindowsWindows Loving ItLoving It

Install Node Js on Windows | Windows 10| Node.Js Latest version

Node Js is cross platform JavaScript Runtime that is used to do server side scripting using Java Script. Install Node.Js on Windows with two easy methods.

Install Node.Js on Windows

Install Node.js on Windows:

In this post, we are going to see how to install node.js on windows.  Here we are going to pay more attention to the latest version of Windows that is Windows 10 1907 and the latest version of Node.Js that is 10.16.1 LTS.  This post is divided into several sections for the convenience of the reader.  The first section talks about what is Node.Js and what are the benefits of choosing it above the other popular offerings such as Apache and PHP etc.

 

nodejs msi
nodejs msi

What is Node.Js?

Node.Js is a runtime environment meant for running the JavaScript code.  It was originally written by Ryan Dahl because he did not like the idea of blocking code architecture implemented by PHP and Apache.

Initially, when PHP and apache were popular, they had a limitation of 10,000 concurrent connections because each request needs to be executed in its own call stack and the stack will occupy the hardware resource until the code is completely executed.  This makes it difficult to use a low spec server for high traffic sites.  Dahl aimed to solve this problem by using the open-source Chrome V8 engine to write a server that works by the non-blocking architecture.  That means that a new request does not need the older request to be completed and it can execute in the same thread.

Also, since the Node.Js is based on the opensource V8 Engine developed by google for its runtime purposes, Node.Js is able to reap the benefits of writing non-blocking JS code with the help of asynchronous, call back functions and more.  This is what gives Node.Js the ability to handle high traffic for the same hardware specs.

We need to keep in mind that Node.Js is only one part of the equation.  If we need to write a fully functional website, we have to write a server and the code that will help the site to function as well.  With Node.Js writing a powerful server is very easy and since we are using JS which is actually the client-side language, we can easily only learn one language and code for the server and the client unline with the other web development stacks.

There are lots of developers who contribute to the Nodel.Js libraries and keeping it relevant in today’s changing world.  And as a Node.Js developer, to get the benefits of all the latest Node.Js features, you have to install a package manager for Node.Js.  All the new features along with the Node.Js server are served to everyone as packages.  These packages are managed using the package manager.  The Node.Js package manager is called NPM.  NPM stands for Node Package Manager.

Now that we have understood what are the benefits of using Node.JS let us see how to install Node.Js.

Install Node.Js on Windows using the Setup File:

We can go to the Node.Js official website and download the latest version of Node.Js.  We can see that there are two downloads available.  One is the Long Time Support and One is the Current.  Current is the latest version of Node.Js.  Let use click on it and get the Setup File.

Official Site
https://nodejs.org/en/
download the MSI
download the MSI

By clicking on current we get the MSI (Microsoft Installer) set up file.  Double click the setup file to initiate the installation.

node js msi double click
node js msi double click
  • Now click on Next.
Install Node.Js on Windows
Install Node.Js on Windows
  • Accept the terms and conditions and click on Next
Install Node.Js on Windows
Install Node.Js on Windows
  • Let it be the default file path and click on Next
Install Node.Js on Windows
Install Node.Js on Windows
  • Click on Next
Install Node.Js on Windows
Install Node.Js on Windows
  • Now click on Next.
Install Node.Js on Windows
Install Node.Js on Windows
  • Now click on Install.
click on Install Node.Js
click on Install Node.Js
  • Now click on Finish.
Finish installing Node.Js on Windows
Finish installing Node.Js on Windows

After that step, we can see that Node.Js is installed in Windows 10.  Press the start button and search for Node and you will find Node.Js here.

Install Node.Js on Windows
Install Node.Js on Windows

Install Node.Js using Chocolatey:

We do not have to completely rely on only the setup file for installing Node.Js in Windows.  We can also use the Node Package Manager for Windows for installing Node on Windows.  The package manager for Windows is called Chocolatey.

Chocolatey is a decentralized package manager for quickly installing the necessary packages.  To install Node.Js using Chocolatey we need to install Chocolatey first.  We can install it from this link.

Official Site
https://chocolatey.org/
chocolatey official site
chocolatey official site

If we click on the link provided we can see that It will navigate to another page that contains the instructions on how to install Node.Js using Chocolatey.  But we do not have to bother with the nitty-gritty details of installing our necessary software and we will follow the given instructions to install Node.Js on Windows.

  • Press the start button and type cmd.
  • Enter the following command in Command Prompt and press enter
cmd in administrative mode
cmd in administrative mode
Chocolatey Command

@”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

Install Chocolatey
Install Chocolatey
  • After the command completes executing, enter choco and press enter.
choco command
choco command
  • If you see the following output, then Chocolatey has installed in the system.
  • Now enter the following command to install Node.Js
Install Node.Js on Windows

cinst nodejs install

Install Node.Js on Windows
Install Node.Js on Windows
  • Now you will see a prompt asking you to enter y/n.
  • Enter y
Enter y in the terminal
Enter y in the terminal

That is all, the Node.Js has installed successfully in your system also.

Writing the first Node.Js Web Site:

In this section, we will write our first Node.Js website.  Now that we have successfully installed Node.Js on our Windows computer, let us write our first Node.Js site.

Below is the source for the first program.

First Node.js program

var http = require(‘http’);

http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type’: ‘text/html’});
res.end(‘TecKangaroo.com’);
}).listen(8080);

Copy and paste the source into a file and save the file as a JavaScript file.  Save the file as a JavaScript file with .Js file extension.

first Node.Js file
first Node.Js file

In our case, we have saved it in a file named TecKangaroo.Js and saved it in the Documents folder.

  • Now we launch Node.Js in the current directory and enter the following command.
Command to run First Node.js program

node teckangaroo.js

  • Now open a browser and enter the following address.
http://localhost:8080
running the first Node site
running the first Node site

Now you will see an output as shown in the image.  This means that Node.Js server is running and returning the following response.

Conclusion:

In this post, we learned how to install the latest version of Node.Js on the latest version of Windows.  We also learned what is Node.js and how it is different from the other servers and programming languages.

Since it is using Js as the primary language, we can say that now we have a way to script for the server and the client using the same language.

If you want more such awesome posts, please stay tuned to TecKangaroo.com

Install Node.js On Windows
  • Author Rating
  • Content Rating
  • Content Relevance
  • Install Node.js on Windows
4.6

Leave a Reply

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

Loading…

0

Comments

0 comments