How to Install Node.js on Rocky Linux 8

Install Node.js on Rocky Linux 8

In this article, we will have explained the necessary steps to install Node.js on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment built on Chrome’s V8 engine to build fast and scalable network applications and back-end APIs. It’s used for traditional websites and back-end API services but was designed with real-time, push-based architectures. It offers users the ability to write websites in JavaScript whose code executes on the server instead of a client’s browser.

Install Node.js on Rocky Linux 8

Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.

sudo dnf update
sudo dnf upgrade

Step 2. Install Node.js on Rocky Linux system.

  • Installing Nodejs from AppStream Repository.

Now check all available repository modules for Node.js on your Rocky Linux system:

sudo dnf module list nodejs

Output:

[[email protected] ~]# sudo dnf module list nodejs
Last metadata expiration check: 4:07:57 ago on Thu 17 Sep 2021 09:11:13 PM EDT.
Rocky Linux 8 - AppStream
Name      Stream    Profiles                                Summary
nodejs    10 [d]    common [d], development, minimal, s2i   Javascript runtime
nodejs    12        common [d], development, minimal, s2i   Javascript runtime
nodejs    14        common [d], development, minimal, s2i   Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

To enable the latest NodeJS stream, run the command:

sudo dnf module install nodejs:14

After that, verify the repository module Node.js using the command below:

node -v

Output:

[[email protected] ~]# node -v
v14.16.2
  • Installing Node.js from Source.

Run the following command to install Node.js from Nodesource Repository:

sudo curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -

Next, run the installation dnf command as follows to install Node.js:

sudo dnf install nodejs

After the installation is complete, verify Node.js and npm running the following command:

node --version

Also, check the nvm version and confirm installation typing:

npm --version

That’s all you need to do to install Node.js on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on PostgreSQL’s open-source database, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.