Best Way to Install Node.js and NPM on Rocky Linux 8 or AlmaLinux

Here we learn the commands to install Nodejs and its package manager NPM on Rocky Linux 8 or AlmaLinux…

Node.js is a framework based on the fastest JavaScript compiler currently available, Google V8. The focus is on high efficiency since asynchronous I/O, i.e. the connection of external resources such as the network or the file system. Since Node.js is based on JavaScript, the entry barrier is correspondingly low, at least for web developers. Node.js is an extremely interesting technology that allows you to develop complex and very scalable web applications with just a few lines of code.

Whereas to download and install various packages & dependencies, Node.js comes with an official package manager called NPM (Node Package Manager).

What do you need to perform this tutorial?

♦ RPM-based Linux server/desktop systems such as Rocky, CentOS, AlamLinux, RHEL, or any other.
♦ A user with sudo access.
♦ Internet connection

 

Command to install Node.js and NPM on Rocky Linux 8

1. Run system update

The first thing we should perform on Linux before installing any software is running the system update command. This will not only update the already installed packages but also refresh the system’s repository cache as well.

sudo dnf update

 

2. Check available Node.js versions to install

To install Nodejs and NPM on Rocky Linux 8 or AlmaLinux, we don’t have to add any repository manually to get the packages for the installation of this Java programing language and its package manager. CentOS and RHEL 8 along with other RPM Linux already have a dedicated module for it.

Let’s see what are versions available on Rocky or AlmaLinux 8 to install

dnf module list nodejs

Output:

Rocky Linux 8 - AppStream
Name Stream Profiles Summary 
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime 
nodejs 12 common [d], development, minimal, s2i Javascript runtime 
nodejs 14 common [d], development, minimal, s2i Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[[email protected] ~]$

Check available Node.js versions to install on Rocky Linux

 

3. Set the Default version to install

In the above screenshot, you can see the available versions are Nodejs 10,12, and 14; whereas Nodejs 10 is set as the default version to install. Hence to enable the latest LTS one that is 14 to install by default on the system, we run the below command:

sudo dnf module enable nodejs:version

For example, I want to enable LTS version 14 of Nodejs to install, the command will be:

sudo dnf module enable nodejs:14

Set the Default version to install

 

4. Command to install Nodejs & NPM on Rocky Linux or AlmaLinux 8

Finally, we have set the version that we want to install, its time to run the below-given command to download the packages to set the Node.js including its package manager.

sudo dnf install nodejs

Command to install Nodejs NPM on Rocky Linux or AlmaLinux 8

 

5.  Check Versions

Once the installation is completed, let’s check the version of the Node and NPM:

node --version
npm --version

Check node and npm versions

This was the simple way to get this programming language on your system. To know more about the commands to use NPM, see the official documentation.

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.