How To Install or Update NodeJs on Rocky Linux
Rocky Linux is a community-supported enterprise operating system designed to be binary-compatible with RHEL (Red Hat Enterprise Linux). To install Node.js on Rocky Linux, you can use either the NodeSource repository or the official package manager, DNF.
Here are the steps to install Node.js using the NodeSource repository:
Method 1: Using NodeSource Repository
-
Add the NodeSource repository:
sudo dnf install -y https://rpm.nodesource.com/pub_16.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm
-
Install Node.js:
sudo dnf install -y nodejs
-
Verify the installation:
node -v npm -v
Method 2: Using DNF (Official Repository)
-
Node.js is available as a module called
nodejs
in CentOS/RHEL 8 and Fedora.sudo dnf module install nodejs:<stream>
-
where <stream> corresponds to the major version of Node.js. To see a list of available versions:
sudo dnf module list nodejs
-
To install the latest NodeJS version, run the command:
sudo dnf module install nodejs:20
-
Verify the installation:
node -v npm -v