Here we learn the commands to install Nodejs and its package manager NPM on Rocky Linux 8 or AlmaLinux…
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
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
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
5. Check Versions
Once the installation is completed, let’s check the version of the Node and NPM:
node --version npm --version
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.