How to install Node JS on your system

The beauty of modern development is that you have powerful tools and frameworks that can significantly boost your productivity. One such tool is Node JS, a run-time environment that allows you to run JavaScript on your server. It’s highly efficient and powers some of the biggest websites globally, such as Netflix, LinkedIn, and Uber.

In this Answer, we will see the process of installing Node JS on your system.

Node JS

Node JS is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside a web browser. It allows us to build scalable network applications and perform asynchronous programming.

Installation of Node JS

You can install Node JS on three major platforms which are Windows, macOS, and Linux. We will discuss the installation process for each of these platforms.

Windows

Let’s first see how to install Node JS on windows.

Download Node JS installer

Firstly, head to the official Node JS website. You will find the Windows Installer under ‘Downloads.’ For most users, the LTS (Long Term Support) version is recommended. Click on the Windows Installer (.msi).

Run the Node JS installer

After the installer is downloaded, run it. You will be guided through the setup process. Accept the license agreement, and keep the default settings unless you have specific requirements.

Test your installation

Once the installation process is complete, you can test it. Open your command prompt and type the following command:

node -v

This command will display the version of Node JS installed on your system, confirming a successful installation.

macOS

To install Node JS on macOS, follow the following steps.

Download Node JS installer

As with Windows, visit the Node JS website and click on macOS Installer (.pkg) under ‘Downloads.’

Run the Node JS installer

After downloading, open the .pkg file and follow the instructions to install Node JS.

Test your installation

To confirm the successful installation, open the Terminal, and run:

node -v

If the Node JS version appears, your installation is successful.

Linux

The installation process on Linux can vary depending on the distribution. Here, we’ll use Ubuntu for our example.

Update your system

Before installation, update your system with the following command:

sudo apt-get update

Install Node JS

Next, install Node JS with the following command:

sudo apt-get install nodejs

Test your installation

Finally, verify the installation with:

node -v

Running your first Node JS program

After successful installation, you’re ready to write and run your first Node JS program. Create a new file hello.js and write the following code:

console.log("Hello, World!");

To run the file, use the node command followed by the filename:

node hello.js

If everything is working correctly, you’ll see Hello, World! printed to your console.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved