How To Install Node.js On Linux?

node js 4
node js 4

For the past couple of years, JavaScript runtime Node.js has become one of the best things to learn if one aims to become a full-stack developer. For starters, Node.js is a JavaScript runtime built on Chrome’s V8 engine, which is written in C++.

The cherry on top is the Node Package Manager, which allows you to use modules developed by others in your project. In this article, let’s see how to install Node.js on Linux to get started with an exciting web development journey:

Installing Node.js On Debian and Ubuntu-based Distributions

We’d highly suggest you install the LTS versions as they have little to no problems compared to the latest versions.

As of writing this article, version 14.15.1 is the latest LTS release. If you’re from the future, replace the “14.x” with the latest LTS version number. This also applies if you want to download the older versions of Node.

On Ubuntu

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

On Debian


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

Installing Node.js On Arch-Based Distributions

Node.js and npm packages are already available in the Community Repository.

pacman -S nodejs npm

Installing Node.js On CentOS, Fedora, And Red Hat Enterprise Linux

The command to install Node.js would be

dnf module install nodejs:14

The field after semi colon is called stream and you can replace it with any number to download that particular version of Node.

Check If The Installation Was Successful

To check if you’ve successfully installed Node.js enter the following command

node -v
npm -v

Install Using Node.js Binary On Ubuntu

  1. The first thing you need to do is head over to nodejs.org and download the latest or LTS binary.

2. Unzip the binary into your desired directory

3. Open up the ~/.profile and add the following code to it.

VERSION=v14.15.1
DISTRO=linux-x64
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs 

4. Save and close ~/.profile. Now enter the commands node -v, npm -v to check if Node.js has been installed.

That’s it with the installation process. Having problems installing? Let us know in the comments section below.

Similar Posts