Node.js is a powerful JavaScript runtime built on Chrome’s V8 JavaScript engine, used for building scalable network applications. This guide will take you through the steps to install Node.js on Rocky Linux 8.
Prerequisites
Before you begin, make sure you have the following:
- A Rocky Linux 8 server.
- A user with
sudo
privileges.
Step 1: Update the System
First, update your package index to ensure all your installed packages are up-to-date:
sudo dnf update
Step 2: Install Node.js
There are multiple ways to install Node.js on Rocky Linux 8. We’ll cover two methods: using the NodeSource repository and using the default Rocky Linux repositories.
Method 1: Using NodeSource Repository
- Add NodeSource Repository:NodeSource provides an up-to-date Node.js package. To add the NodeSource repository, use the following command:curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash –
- This script will add the NodeSource repository to your system and update the package index.
- Install Node.js:After adding the repository, install Node.js using the following command:sudo dnf install nodejs
Method 2: Using Rocky Linux Default Repositories
- Install Node.js:If you prefer to use the default Rocky Linux repositories, you can install Node.js directly:sudo dnf module list nodejsThis command will show you the available Node.js versions. Install your preferred version with:sudo dnf module install nodejs:14
Step 3: Verify the Installation
After installing Node.js, verify the installation by checking the installed version of Node.js and npm (Node Package Manager):
node -v
npm -v
These commands should display the version numbers of Node.js and npm, confirming that the installation was successful.
Step 4: Install Development Tools (Optional)
If you plan to compile and install native add-ons from npm, you may need to install development tools. Use the following command to install the necessary tools:
sudo dnf groupinstall “Development Tools”
Conclusion
Congratulations! You’ve successfully installed Node.js on Rocky Linux 8. You can now start building and deploying Node.js applications on your server.