Skip to main content

Installing Node.js and NPM on AlmaLinux

Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to build both frontend and backend applications using JavaScript. It runs on various platforms such as Linux, macOS, and Windows, and is powered by the V8 JavaScript engine. One of its key advantages is its asynchronous, event-driven model, which makes it memory-efficient and supports non-blocking, concurrent operations. Node.js is widely used for building network applications like web servers, and it has a large ecosystem of open-source libraries, which are available through npm (Node Package Manager). NPM is an essential part of Node.js, enabling developers to manage dependencies, install packages, and handle versions of libraries with ease.

Prerequisites

Before proceeding with the installation, make sure you have access to a running AlmaLinux system.

Step 1: Update and Upgrade Your System

Start by ensuring that your system is up to date. Run the following commands to update the repositories and upgrade all installed packages:

sudo yum update -y && sudo yum upgrade -y   

Step 2: Enable the EPEL Repository

The EPEL (Extra Packages for Enterprise Linux) repository contains additional software packages, including Node.js. To install Node.js, you need to enable this repository by installing the epel-release package:

sudo yum install epel-release -y   

This will configure your system to access the EPEL repository and allow you to install additional packages.

Step 3: Install Node.js

Once the EPEL repository is set up, you can install Node.js using the yum package manager. This will install both Node.js and npm by default:

sudo yum install nodejs -y   

After the installation is complete, verify that Node.js was installed successfully by checking its version:

node --version   

This command will display the version of Node.js installed, confirming that the installation was successful.

Step 4: Install NPM (Node Package Manager)

In most cases, npm (Node Package Manager) is installed alongside Node.js. However, if for some reason it wasn't installed, you can install it manually using the following command:

sudo yum install npm -y   

To confirm that npm has been installed correctly, you can check its version:

npm --version   

This will display the installed version of npm, ensuring that everything is set up properly.

Conclusion

You have now successfully installed Node.js and npm on your AlmaLinux server. You can start using Node.js to build your applications and use npm to manage dependencies for your projects. With this setup, you're ready to take advantage of Node.js’s event-driven architecture and the vast ecosystem of packages available via npm.