How to Install Node.js in Linux, Windows, and Mac

Node.js is a popular platform for building server-side applications using JavaScript. It allows developers to use the same language and programming paradigm for both the front-end and back-end of their web applications, providing a consistent development experience.

But installing Node.js on different operating systems, such as Linux, Windows, and Mac, can be challenging, especially if you are new to the platform.

This article will provide a step-by-step guide on how to install Node.js on each of these operating systems.

What is Node.js?

Node.js is a platform that allows developers to run JavaScript code outside of a web browser. It is not a popular programming language but rather an environment that uses the V8 JavaScript engine from Google Chrome to execute code on a server-side platform.

This means that developers can use the same language and syntax for client-side and server-side programming, streamlining the development process and improving productivity. Notably, this runtime environment is ideal for building scalable, high-performance applications that handle many concurrent connections.

It is beneficial for building real-time applications like chat systems, collaborative tools, and streaming services. In addition, Node.js has a vast library of modules and packages available through its package manager, npm, which simplifies the development process and provides a wealth of resources for developers.

Benefits of Using Node.js

One major benefit of Node.js is that it allows developers to use JavaScript on both the front-end and back-end, which makes it easier to build and maintain web applications. This means that developers can use a single language and syntax for both client-side and server-side programming, simplifying the development process and making it more efficient.

Secondly, Node.js can handle several concurrent connections, making it ideal for building real-time applications such as chat systems, collaborative tools, and streaming services. The platform achieves this by using an event-driven, non-blocking I/O model, which allows it to handle multiple requests simultaneously without blocking the thread.

Node.js also has a vast library of modules and packages available through its package manager, npm, which can save developers time and effort by providing pre-built solutions for everyday tasks and functionalities.

Finally, Node.js is popular for its scalability, which means it can easily handle increased traffic and workloads as an application grows. This makes it a popular choice for building large-scale web applications that can handle high levels of traffic and data.

Node.js Installation Prerequisites

The system requirements for installing Node.js depend on your operating system.

For Linux:

For Windows:

  • Windows 7 or later
  • 32-bit or 64-bit processor
  • 512 MB of RAM or more

For macOS:

  • macOS 10.10 or later
  • 64-bit processor
  • 512 MB of RAM or more

In addition to these basic requirements, you’ll also need to ensure that your system has a recent version of a web browser and a text editor for writing and editing code.

It’s worth noting that the specific system requirements for Node.js can vary depending on the version you are installing, as well as any dependencies or packages you need to use.

So be sure to check the documentation for the specific version of Node.js you plan to install to ensure that your system meets the necessary requirements.

Installing Node.js on Linux Systems

Notably, there are two methods for installing Node.js on Linux.

Using NodeSource Repo

The NodeSource repository provides multiple versions of Node.js releases as shown:

On RHEL-based Distributions

------------- For Node.js v19.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_19.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v18.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v16.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
$ sudo yum install -y nodejs

------------- For Node.js v14.x ------------- 
$ curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -
$ sudo yum install -y nodejs

On Debian-based Distributions

------------- For Node.js v19.x ------------- 
$ curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v18.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v16.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

------------- For Node.js v14.x -------------
$ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
$ sudo apt-get install -y nodejs

That’s it! You now have Node.js and npm installed on your Linux system. You can start building applications using Node.js and npm by creating a new project and installing the required packages using the npm command.

Using NVM (Node Version Manager)

Another popular method of installing Node.js on Linux is the Node Version Manager, which is used to install and manage various Node.js versions in your system.

$ sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
$ sudo nvm install node
$ node -v

You now have Node.js installed on your Linux system using nvm, and you can start using it to build applications.

Install Node.js on Windows System

similarly, there are two methods for installing Node.js on Windows.

Node.js Windows Installer

You can install Node.js on your Windows system using the official Node.js installer, which can be downloaded from the Node.js website.

Install Node.js in Windows
Install Node.js on Windows

To verify that Node.js is installed correctly, open a Command Prompt window and run the command node -v, which should output the version of Node.js that you have installed.

Using Chocolatey Package Manager

Alternatively, you can install Node.js on your Windows device using the Chocolatey package manager as shown;

If you don’t already have Chocolatey installed, open a Command Prompt window with administrator privileges and run the following command to install it.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Once you have Chocolatey running, you can proceed to install Node.js using the below command.

choco install nodejs

To verify that Node.js is installed correctly, open a Command Prompt window and run the command, which should output the version of Node.js that you have installed.

node -v

That’s all for Windows systems. You now have Node.js installed on your Windows system using either the official installer or Chocolatey package manager and you can start using it to build applications.

Install Node.js on macOS

You can also install Node.js on your macOS device using two methods, including:

Using Homebrew Package Manager

Firstly, you can use the Homebrew package manager to have Node.js installed on your macOS device.

You can bypass this step if you already have Homebrew installed on your machine. However, open the terminal window and run the following command to install it, if not installed.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed, run the following command to install Node.js.

brew install node

Once the installation is complete, you can verify that Node.js is installed correctly by running the below utility in your terminal.

node -v

Node.js Mac Installer

You can also install Node.js on your macOS using the official installer, which can be downloaded from the official Node.js website.

Install Nodejs in Mac
Install Nodejs on Mac

To verify that Node.js is installed correctly, you can run the command node -v in your terminal, which should output the version of Node.js that you have installed.

You now have Node.js installed on your macOS system using either Homebrew or the official installer, and you can start using it to build applications.

How to Update Node.js Version

To update Node.js to the latest version, you can use the Node Version Manager (nvm) or the package manager you used to install Node.js (such as Homebrew, Chocolatey, or the official installer).

We will demonstrate how to update Node.js using the Node Version Manager (nvm) as it cuts across all the operating systems.

To update Node.js, Open a terminal window and run the following command to update nvm to the latest version:

nvm install-latest-npm

You can then run the below command to update Node.js to its latest version.

nvm install node

To verify that Node.js is updated correctly, you can run the command node -v in your terminal, which should output the latest version of Node.js that you have installed.

Conclusion

Node.js is a robust JavaScript runtime environment allowing developers to build scalable, high-performance applications. Installing Node.js on Linux, Windows, and Mac can be done using different methods, but the steps are easy to follow.

And with Node.js in your toolkit, you’ll be able to create fast and efficient web applications that can scale to meet the demands of modern web development. Which topic would you want us to discuss next?

If you read this far, tweet to the author to show them you care. Tweet a thanks
I am a computer scientist with a bias for data science, system management, and technical content development. My experience in the profession dates back to 2015. I read novels, jog, or play table tennis whenever I am not on gadgets.

Each tutorial at GeeksVeda is created by a team of experienced writers so that it meets our high-quality standards.

Join the GeeksVeda Weekly Newsletter (More Than 5,467 Programmers Have Subscribed)
Was this article helpful? Please add a comment to show your appreciation and support.

Got Something to Say? Join the Discussion...