How to Install Node.js on Windows?

Environment Setup for Node.js

Since Node.js is a mandatory section of the program that runs JavaScript, similar to all other required section of programs that run a programming language, it is usually straightforward to introduce. Node.js provides a rich library of several JavaScript modules to make things easier for developing web applications.

Node JS has been delivered in more than 15 significant versions, with some versions speaking to Long Term Support (LTS) discharges - which means they are used for a longer timeframe, roughly 30 months. Whereas other versions have speedier shorter time frames - which implies when another version is delivered, roughly every six months, the earlier version is no longer refreshed.

For setting up a local environment for Node.js, we need the following two software – The Node.js binary installable and Text Editor.

The Node.js Runtime

In this tutorial, we will be using the latest version (14.13.1 current) that is available at the website link given below:

https://nodejs.org/en/

How to Install Node.js on Windows

Here, you can download the recommended version for your device.

Note: For this tutorial, we will be using Windows (x64), but the process may vary as per your operating system. However, the result would be the same.

Steps to Install Node.js in Windows

Step1: Once the download is completed, you can Run the Setup.

How to Install Node.js on Windows

Step 2: Click on Next to Continue.

How to Install Node.js on Windows

Step 3: Accept the Terms & Conditions, & Click on Next.

How to Install Node.js on Windows

Step 4: Select the destination folder for installation & Click on Next.

How to Install Node.js on Windows
How to Install Node.js on Windows

Step 5: Choose the recommended settings, and Get ready to Install.

How to Install Node.js on Windows
How to Install Node.js on Windows

Step 6: Once Node.js is installed, Click on Finish to complete the setup.

Once you effectively install Node.js, the bin folder will contain the executables as follows:

  • node – node is a JavaScript interactive shell. It is also known as read–eval–print loop (REPL). It is created to instantly access JavaScript statements and to perform the same as other programming language REPLs.
  • npm – npm is a JavaScript package manager, which is created to manage JavaScript packages in Node.js. It is used to download package directly from remote repositories.
  • npx – npx is a complementary tool to npm created to perform JavaScript packages installed on Node.js.

Text Editor for Node.js

The Text Editor is a software that is used to type the program. Some examples include Notepad, Notepad++, Brief, OS Edit command, Visual Studio Code and many more. Apart from Text Editor, there are Integrated Development Environment (IDE) for typing the codes. An integrated development environment is a product application that gives complete services to developers for program development. An IDE ordinarily comprises at least a source code editor, build automation tool and a debugger.

Here, we will be using the Visual Studio Code that is available for Windows as well as MacOS and Linux. You can also download and install the stable version from the official website: https://code.visualstudio.com.

How to Install Node.js on Windows

Verify the installation: Executing Files

To check whether the node.js is installed correctly and entirely on our computer, we will follow a set of procedures.

Step 1: Open Command Prompt (or Terminal in MacOS or Linux).

Step 2: Type the following command: node -v, and Enter.

Executing the above syntax will give an output as follows:

How to Install Node.js on Windows

Here, as you can see, the node command is the primary Node.js executable. It is one of 3 significant binaries comprised with Node.js. The node executable can be understood as identical to a JavaScript executable on the off chance that you have experienced with another programming language.

Similar to all other fundamental executables in programming language run-time environments, the Node.js node command has an abundance of alternatives and environmental factors, you can use to adjust its default performance, which incorporates practices for examining safety, reporting and test highlights, in addition to other things.

 If we execute node with the -v flag, which stands for version, will provide an output in terms of version (e.g., v14.13.0).

We can also execute --help flag after node command to see a list of more than 50 Node.js options and more than 15 node.js environment variables.

Node.js First Example

As we've talked a lot about Node.js, let us use it for executing a simple program.

Create a js file named hello.js in any text editor having the following code:

/* Printing' Hello World!' in node.js*/
console.log("Hello World!")

Now execute hello.js using Node.js interpreter to see the output –

$ node hello.js

It will give you an output as follows:

Hello, World!
How to Install Node.js on Windows