the process of installing Node.js on Rocky Linux 8 is similar to other Red Hat-based distributions. Please note that there might be updates or changes, so it's a good idea to check the official documentation for the latest information. Here's a general guide on how you can install Node.js on Rocky Linux 8:
Using the NodeSource Repository:-
Install the EPEL Repository:
sudo dnf install epel-release
-
Install the NodeSource repository:
sudo dnf install https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm
You can check for the latest version on the NodeSource distributions page.
-
Install Node.js:
Once the repository is added, you can install Node.js using
dnf
:sudo dnf install nodejs
-
Verify the installation:
Check that Node.js and npm (Node Package Manager) are installed and display their versions:
node -v npm -v
Rocky Linux 8 includes the dnf
package manager, so you can also install Node.js directly from the default repositories:
sudo dnf install nodejs
Using NVM (Node Version Manager):
Another option is to use NVM, which allows you to manage multiple Node.js versions on your system:
-
Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Close and reopen your terminal or run:
source ~/.bashrc
For other shells, refer to the NVM documentation.
-
Install Node.js using NVM:
nvm install node
This installs the latest version of Node.js. You can specify a different version if needed.
-
Verify the installation:
node -v npm -v
Choose the method that best fits your needs. Installing from the NodeSource repository or using NVM provides more flexibility in managing Node.js versions. Always refer to the official documentation or sources for the latest and most accurate information.