How To Install Node.JS On Linux (2024)

Start the simple hiring process with Upstack today.

Node.js is an open-source, back-end JavaScript runtime environment that enables developers to execute JavaScript code without a browser. Built on Google Chrome's V8 JavaScript engine, Node.js is a popular platform for creating solutions that require speed and scalability.

One of the core features of this runtime environment is that it is cross-platform. Developers can deploy it on Windows, macOS, and Linux. Node.js also supports both 32-bit and 64-bit environments. In addition to supporting the x86 CPU architecture, it can also run on specific ARM platforms. Node.js is also available as a Docker image and can also run on the IBM PowerLinux, System z, and AIX platforms.

As Node.js has been around since 2009, there are currently 16 versions of this platform available. If you want to install the latest version, you can either choose the current version, which has all the latest features, or the Long Term Support (LTS) version. The option you select is entirely dependent on your requirements. If you are deploying Node.js to production, then LTS is the better option as you will be able to update and patch it as the core team releases security updates and new features.

Installing Node.js on Linux

When installing Node.js on Linux, you can follow one of two methods. You can use the package manager for your particular Linux distribution or compile and build Node.js from its source code.

Both approaches have their advantages and disadvantages. However, using a package manager is far more straightforward as it is typically a one-line command. On the other hand, compiling and building the solution from source code is a little more complex but does give you absolute control over the process. It is also more secure as you can review the code before you compile and build it.

Installing Node.js via Package Manager

Node.js gives you the option to install it using the package manager of your relevant Linux distribution. Due to its popularity, there is a Node.js install package for every popular Linux platform. There are packages available ranging from Android, Arch Linux, and Ubuntu to FreeBSD, Gentoo, and openSUSE. The respective distribution package managers maintain and support each package. As the Node.js core team does not manage these, you need to ensure that the package you are installing contains the version you require. Typically, the package version lags either a few hours or, in some cases, days or weeks behind the source code released by the Node.js core team.

Android

Node.js on Android is still in the experimental phase. However, if you want to install Node.js on Android, you can leverage a terminal emulator like Termux that enables you to perform Linux development for Android. To install Node.js on the Termux app, you need to run the following command:

pkg install nodejs

Arch Linux

The Arch Linux community repository contains both the Node.js and Node Package Manager (npm) packages. You can install both using this command:

pacman -S nodejs npm

CentOS, Fedora, and Red Hat Enterprise Linux (RHEL)

If you want to install Node.js on CentOS/RHEL 8 and Fedora, the package is available as a module. You will also need to specify the stream parameter in the command that corresponds to the version you require. For example, the line below will install Node.js version 12.

dnf module install nodejs:12

If you want to install Node.js on CentOS/RHEL 7, you can do so via the Software Collections gallery.

Debian and Ubuntu

To install Node.js on Debian or Ubuntu-based distributions, you can access the binaries via NodeSource. As with Centos/RHEL 8 and Fedora, you will also need to specify the version number. The installation requires two commands. The first command downloads the setup file via curl, and the second command installs Node.js on the system. The example below details the command-line code needed to install Node.js 12 on Debian and Ubuntu.

# Using Ubuntu

curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root

curl -fsSL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

Gentoo

If Gentoo is your Linux distribution of choice, Node.js is available in the portage tree. You can install via the command:

emerge nodejs

openSUSE and SUSE Linux Enterprise (SLE)

There are several Node.js packages available depending on the version of OpenSUSE or SLE you are running, as detailed in the list below.

  • openSUSE Leap 42.2: nodejs4
  • openSUSE Leap 42.3: nodejs4, nodejs6
  • openSUSE Tumbleweed: nodejs4, nodejs6, nodejs8
  • SUSE Linux Enterprise Server (SLES) 12: nodejs4, nodejs6

You can install the relevant package on your OpenSUSE distribution using zypper. The example below details the command to install Node.js 4.x on openSUSE Leap 42.2.

zypper install nodejs4

Snap

If your Linux distribution supports snaps, you can also install Node.js via the Snap store.

Installing Node.js via Source Code

If you want to install Node.js from source code, you will need to follow the three-step process below. The commands may differ for each Linux distribution depending on its default package manager. The example below specifies the command-line entries for the Ubuntu distribution.

Step 1: Install the build tool prerequisites.

sudo apt update
sudo apt install make g++ libssl-dev git
How To Install Node.JS On Linux (1)

Step 2: Download the Node.js source files.

You can find the latest source and LTS files at Download | Node.js (nodejs.org), as shown in the image below. In this example, we will be installing the LTS version (14.16.1).

How To Install Node.JS On Linux (2)

First, change the directory to tmp for the download.

cd /tmp

Next, use wget to download the source code.

wget https://nodejs.org/dist/v14.16.1/node-v14.16.1.tar.gz
How To Install Node.JS On Linux (3)

Once wget has completed the download, extract the code and then navigate to the extracted directory.

tar -xvf node-v14.16.1.tar.gz
cd node-v14.16.1
How To Install Node.JS On Linux (4)

Step 3: Configure and build the solution.

You are now ready to configure and build the solution by running the following commands.

sudo ./configure

You may run into an error that states, "Build: No module named 'distutils.spawn'".

How To Install Node.JS On Linux (5)

You can run the following command to install the relevant code

sudo apt install python3-distutils -y

Once you have executed the command ./configure successfully, you need to run make. Note that you need to specify the number of CPUs. In the code example below, the server has two CPUs, so the switch is set to j2.

sudo make -j2

Once the making process has completed, which may take a while, you can then run the following command to install Node.js.

sudo make install

Step 4: Test and confirm.

Once you have installed Node.js, you can test to see if the installation was successful.

From a command line type:

node -v

If you see the version number as per the image below, your install was successful.

How To Install Node.JS On Linux (6)
At Upstack we help you grow your business faster. We connect you with the top 1% Node.js developers in the world. Contact us NOW! Learn why Upstack is the best toptal alternative.
How To Install Node.JS On Linux (2024)
Top Articles
What are net 7 payment terms?
Understanding Credit Card Insurance Protection
Po Box 7250 Sioux Falls Sd
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Avonlea Havanese
Obituary (Binghamton Press & Sun-Bulletin): Tully Area Historical Society
Best Theia Builds (Talent | Skill Order | Pairing + Pets) In Call of Dragons - AllClash
Barstool Sports Gif
Acbl Homeport
Azeroth Pilot Reloaded - Addons - World of Warcraft
Bros Movie Wiki
Springfield Mo Craiglist
Love In The Air Ep 9 Eng Sub Dailymotion
Midlife Crisis F95Zone
Craftology East Peoria Il
Eva Mastromatteo Erie Pa
Mzinchaleft
Palm Coast Permits Online
NHS England » Winter and H2 priorities
Bj Alex Mangabuddy
Unity - Manual: Scene view navigation
Governor Brown Signs Legislation Supporting California Legislative Women's Caucus Priorities
Hampton University Ministers Conference Registration
Jordan Poyer Wiki
How to Make Ghee - How We Flourish
Walmart Pharmacy Near Me Open
Beaufort 72 Hour
Kroger Feed Login
4Oxfun
JVID Rina sauce set1
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Ou Football Brainiacs
Miles City Montana Craigslist
Angel Haynes Dropbox
Publix Christmas Dinner 2022
Craftsman Yt3000 Oil Capacity
Motor Mounts
Kamzz Llc
4083519708
Second Chance Apartments, 2nd Chance Apartments Locators for Bad Credit
Pain Out Maxx Kratom
6576771660
Here's Everything You Need to Know About Baby Ariel
Lady Nagant Funko Pop
Port Huron Newspaper
Crigslist Tucson
Devotion Showtimes Near Showplace Icon At Valley Fair
552 Bus Schedule To Atlantic City
Diccionario De Los Sueños Misabueso
Sam's Club Fountain Valley Gas Prices
Latest Posts
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 6272

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.