sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install Node.js on Rocky Linux 9 With 3 Different Ways
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install Node.js on Rocky Linux 9 With 3 Different Ways

Samuel Siahaan
By Samuel Siahaan
Last updated: March 20, 2023
SHARE

Introduction of Node.js

Node.js is a powerful JavaScript runtime environment that is widely used for server-side and web development. At the present time Node.js has revolutionized web development with its versatile capabilities and efficient runtime environment. If you’re running an Rocky Linux 9 and want to harness the power of Node.js for your web projects, for that reason this step-by-step guide will walk you through how to install Node.js on Rocky Linux 9 With 3 Different Ways.

Contents
Introduction of Node.jsTable of ContentsPrerequisites for Install Node.jsSystem Update for Install Node.jsMethod 1: Install Node.js with dnf from the Default RepositoriesInstall Node.js with Default RepositoriesVerify Node.js InstallationMethod 2: Install Node.js Using the NodeSource RepositoryAdd the NodeSource Repository:Install Node.js Using the NodeSourceVerify Node.js InstallationMethod 3: Install Node.js Using the Node Version ManagerInstall NVMSource NVMInstall Node.js with NVMVerify Node.js InstallationConclusion

As I have said, we’ll take you step by step through the process of installing Node.js on Rocky Linux 9. We’ll cover three different methods: the Default repository, the NodeSource repository, and the Node Version Manager (NVM).

Table of Contents

  • Introduction of Node.js
  • Prerequisites for Install Node.js
    • System Update for Install Node.js
    • Method 1: Install Node.js with dnf from the Default Repositories
      • Install Node.js with Default Repositories
      • Verify Node.js Installation
    • Method 2: Install Node.js Using the NodeSource Repository
      • Add the NodeSource Repository:
      • Install Node.js Using the NodeSource
      • Verify Node.js Installation
    • Method 3: Install Node.js Using the Node Version Manager
      • Install NVM
      • Source NVM
      • Install Node.js with NVM
      • Verify Node.js Installation
  • Conclusion

Node.js has become incredibly popular for modern web development, especially for applications requiring real-time interactions, such as chat applications, streaming services, and online gaming platforms. Even more Its performance, scalability, and extensive package ecosystem have made it a favorite among developers for building a wide range of applications and services.

Prerequisites for Install Node.js

Important to realize this guide assumes that you are using Rocky Linux 9 for install Node.js. Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following below tutorial :

- Advertisement -
  • Initial Setup Rocky Linux 9 Server: Secure and Efficient

System Update for Install Node.js

Basically It’s always a good practice to start by updating your package repository and upgrading installed packages to their latest versions. Update the package lists by running the following command:

Bash
[samm@node-js ~]$ sudo dnf update -y

[samm@node-js ~]$ sudo dnf upgrade --refresh
Extra Packages for Enterprise Linux 9 - x86_64                                                                                                                                     9.5 kB/s | 6.5 kB     00:00    
Extra Packages for Enterprise Linux 9 - x86_64                                                                                                                                     4.5 MB/s |  18 MB     00:04    
Rocky Linux 9 - BaseOS                                                                                                                                                             2.1 kB/s | 4.1 kB     00:01    
Rocky Linux 9 - AppStream                                                                                                                                                          3.3 kB/s | 4.5 kB     00:01    
Rocky Linux 9 - Extras                                                                                                                                                             1.8 kB/s | 2.9 kB     00:01    
Dependencies resolved.
Nothing to do.
Complete!

[samm@node-js ~]$ sudo dnf install dnf-utils

In this guide, given these points you will review three different ways of getting Node.js installed on a Rocky Linux 9 server:

  • Using dnf to install the nodejs package from Rocky’s default software repository.
  • Using dnf with the Nodesource software repository to install specific versions of the nodejs package
  • Installing nvm, the Node Version Manager, and using it to install and manage multiple versions of Node.js

Method 1: Install Node.js with dnf from the Default Repositories

Basically Rocky Linux 9 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. At this time of writing, the version in the repositories is v16.19.1. This will not be the latest version, but it should be stable and sufficient for quick experimentation with the language.

Install Node.js with Default Repositories

To get this version, you can use the dnf package manager by running the following command:

Bash
[samm@node-js ~]$ sudo dnf install nodejs -y
Last metadata expiration check: 0:54:33 ago on Fri 28 Jul 2023 07:05:11 PM WIB.
Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                             Architecture                              Version                                                          Repository                                    Size
===================================================================================================================================================================================================================
Installing:
 nodejs                                              x86_64                                    1:16.19.1-2.el9_2                                                appstream                                    111 k
Installing dependencies:
 nodejs-libs                                         x86_64                                    1:16.19.1-2.el9_2                                                appstream                                     14 M
Installing weak dependencies:
 nodejs-docs                                         noarch                                    1:16.19.1-2.el9_2                                                appstream                                    7.0 M
 nodejs-full-i18n                                    x86_64                                    1:16.19.1-2.el9_2                                                appstream                                    8.2 M
 npm                                                 x86_64                                    1:8.19.3-1.16.19.1.2.el9_2                                       appstream                                    1.7 M

Transaction Summary
===================================================================================================================================================================================================================
Install  5 Packages

Total download size: 32 M
Installed size: 168 M

Verify Node.js Installation

Then check the install was successful by querying node for its version number:

- Advertisement -
Bash
[samm@node-js ~]$ node -v

Output

Bash
v16.19.1

If the package in the repositories suits your needs, then this is all you need to do to get set up with Node.js. The Node.js package from Rocky’s default repositories also comes with npm, the Node.js package manager.

At this point you have successfully installed Node.js and npm using dnf and the default Rocky software repositories. Henceforth the next section will show you how to use an alternate repository to install different versions of Node.js.

- Advertisement -

Method 2: Install Node.js Using the NodeSource Repository

In another case to install a different version of Node.js, you can use the NodeSource repository.

Add the NodeSource Repository:

First, you’ll need to configure the repository locally, in order to get access to its packages.

Bash
[samm@node-js ~]$ curl -sL https://rpm.nodesource.com/setup_18.x -o nodesource_setup.sh

In detail about the available versions, check out the NodeSource documentation.

Now, run the script with sudo using following command:

Bash
[samm@node-js ~]$ sudo bash nodesource_setup.sh

Then you should see the output similar to the following:

Bash
## Installing the NodeSource Node.js 18.x repo...


## Inspecting system...

+ uname -m
rocky-release-9.2-1.6.el9.noarch
exec redhat-release
Release package: rocky-release-9.2-1.6.el9.noarch

## Confirming "el9-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_18.x/el/9/x86_64/nodesource-release-el9-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.RYY47cxmpV' 'https://rpm.nodesource.com/pub_18.x/el/9/x86_64/nodesource-release-el9-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.RYY47cxmpV'

## Cleaning up...

+ rm -f '/tmp/tmp.RYY47cxmpV'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Your system appears to already have Node.js installed from an alternative source.
Run `sudo yum remove -y nodejs npm` to remove these first.

## Run `sudo yum install -y nodejs` to install Node.js 18.x and npm.
## You may run dnf if yum is not available:
     sudo dnf install -y nodejs
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

Install Node.js Using the NodeSource

At this point the repository will be added to your configuration and your local package cache will be updated automatically. You can now install the Node.js package in the same way you did in the previous section. It may be a good idea to fully remove your older Node.js packages before installing the new version, by using sudo dnf remove nodejs npm.

This won’t change your settings in any way; but only update the installed software versions. Must be remembered that third-party repositories may not always package their software in a manner that seamlessly upgrades over the default packages. If you encounter any issues, for this reason you can always go back to the original, unmodified setup as a fallback option.

Use following command:

Bash
[samm@node-js ~]$ sudo dnf remove nodejs npm -y
Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                             Architecture                              Version                                                         Repository                                     Size
===================================================================================================================================================================================================================
Removing:
 nodejs                                              x86_64                                    1:16.19.1-2.el9_2                                               @appstream                                    369 k
 npm                                                 x86_64                                    1:8.19.3-1.16.19.1.2.el9_2                                      @appstream                                    6.5 M
Removing unused dependencies:
 nodejs-docs                                         noarch                                    1:16.19.1-2.el9_2                                               @appstream                                     76 M
 nodejs-full-i18n                                    x86_64                                    1:16.19.1-2.el9_2                                               @appstream                                     29 M
 nodejs-libs                                         x86_64                                    1:16.19.1-2.el9_2                                               @appstream                                     56 M

Transaction Summary
===================================================================================================================================================================================================================
Remove  5 Packages

Freed space: 168 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                           1/1 
  Erasing          : nodejs-1:16.19.1-2.el9_2.x86_64                                                                                                                                                           1/5 
  Erasing          : npm-1:8.19.3-1.16.19.1.2.el9_2.x86_64                                                                                                                                                     2/5 
  Erasing          : nodejs-docs-1:16.19.1-2.el9_2.noarch                                                                                                                                                      3/5 
  Erasing          : nodejs-full-i18n-1:16.19.1-2.el9_2.x86_64                                                                                                                                                 4/5 
  Erasing          : nodejs-libs-1:16.19.1-2.el9_2.x86_64                                                                                                                                                      5/5 
  Running scriptlet: nodejs-libs-1:16.19.1-2.el9_2.x86_64                                                                                                                                                      5/5 
  Verifying        : nodejs-1:16.19.1-2.el9_2.x86_64                                                                                                                                                           1/5 
  Verifying        : nodejs-docs-1:16.19.1-2.el9_2.noarch                                                                                                                                                      2/5 
  Verifying        : nodejs-full-i18n-1:16.19.1-2.el9_2.x86_64                                                                                                                                                 3/5 
  Verifying        : nodejs-libs-1:16.19.1-2.el9_2.x86_64                                                                                                                                                      4/5 
  Verifying        : npm-1:8.19.3-1.16.19.1.2.el9_2.x86_64                                                                                                                                                     5/5 

Removed:
  nodejs-1:16.19.1-2.el9_2.x86_64     nodejs-docs-1:16.19.1-2.el9_2.noarch     nodejs-full-i18n-1:16.19.1-2.el9_2.x86_64     nodejs-libs-1:16.19.1-2.el9_2.x86_64     npm-1:8.19.3-1.16.19.1.2.el9_2.x86_64    

Complete!

After fully remove your older Node.js packages, then install the new version of Node.js

Bash
[samm@node-js ~]$ sudo dnf install nodejs -y
Node.js Packages for Enterprise Linux 9 - x86_64                                                                                                                                   2.2 MB/s | 623 kB     00:00    
Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                       Architecture                                  Version                                                       Repository                                         Size
===================================================================================================================================================================================================================
Installing:
 nodejs                                        x86_64                                        2:18.17.0-1nodesource                                         nodesource                                         34 M

Transaction Summary
===================================================================================================================================================================================================================
Install  1 Package

Total download size: 34 M
Installed size: 100 M
Downloading Packages:
nodejs-18.17.0-1nodesource.x86_64.rpm                                                                                                                                              4.4 MB/s |  34 MB     00:07    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                              4.4 MB/s |  34 MB     00:07     
Node.js Packages for Enterprise Linux 9 - x86_64                                                                                                                                   1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <[email protected]>"
 Fingerprint: 2E55 207A 95D9 944B 0CC9 3261 5DDB E8D4 34FA 74DD
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                           1/1 
  Running scriptlet: nodejs-2:18.17.0-1nodesource.x86_64                                                                                                                                                       1/1 
  Installing       : nodejs-2:18.17.0-1nodesource.x86_64                                                                                                                                                       1/1 
  Running scriptlet: nodejs-2:18.17.0-1nodesource.x86_64                                                                                                                                                       1/1 
  Verifying        : nodejs-2:18.17.0-1nodesource.x86_64                                                                                                                                                       1/1 

Installed:
  nodejs-2:18.17.0-1nodesource.x86_64                                                                                                                                                                              

Complete!

Verify Node.js Installation

After that verify that you’ve installed the new version. by running node with the -v version flag:

Bash
[samm@node-js ~]$ node -v

Output

Bash
v18.17.0

The NodeSource nodejs package contains both the node binary and npm, so you don’t need to install npm separately.

At this point you have successfully installed Node.js and npm using dnf and the NodeSource repository. Finally the next section will show how to use the Node Version Manager to install and manage multiple versions of Node.js.

Method 3: Install Node.js Using the Node Version Manager

Another way of installing Node.js that is particularly flexible is to use nvm, the Node Version Manager. This piece of software allows you to install and maintain many different independent versions of Node.js, and their associated Node packages, at the same time.

Install NVM

Before piping the command through to bash, it is always a good idea to audit the script to make sure it isn’t doing anything you don’t agree with. You can do that by removing the | bash segment at the end of the curl command:

Bash
[samm@node-js ~]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh

With the result that, review the modifications it’s introducing and make sure you feel at ease with them.. When you are satisfied, run the command again with | bash added at the end. The URL you use will change depending on the latest version of nvm, but as of right now, the script can be downloaded and executed by typing:

Bash
[samm@node-js ~]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

After that this will install the nvm script to your user account.

Source NVM

In order that to use it. You must first source your .bashrc file:

Bash
[samm@node-js ~]$ source ~/.bashrc

Now, you can ask NVM which versions of Node are available by using following command:

Bash
Output
. . .
       v18.11.0
       v18.12.0   (LTS: Hydrogen)
       v18.12.1   (LTS: Hydrogen)
       v18.13.0   (LTS: Hydrogen)
       v18.14.0   (LTS: Hydrogen)
       v18.14.1   (LTS: Hydrogen)
       v18.14.2   (LTS: Hydrogen)
       v18.15.0   (LTS: Hydrogen)
       v18.16.0   (LTS: Hydrogen)
       v18.16.1   (LTS: Hydrogen)
       v18.17.0   (Latest LTS: Hydrogen)
       v19.0.0
       v19.0.1
. . .

As can be seen it’s a very long list! Afterwards you can install a version of Node by typing any of the release versions you see.

Install Node.js with NVM

For instance, to get version v18.17.0 (an LTS release), you can type:

Bash
[samm@node-js ~]$ nvm install v18.17.0

You should then see the output similar to the following:

Bash
Downloading and installing node v18.17.0...
Downloading https://nodejs.org/dist/v18.17.0/node-v18.17.0-linux-x64.tar.xz...
############################################################################################################################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v18.17.0 (npm v9.6.7)

Verify Node.js Installation

You can see the different versions you have installed by typing following command:

Bash
[samm@node-js ~]$ nvm list

->     v18.17.0
         system
default -> v18.17.0
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.17.0) (default)
stable -> 18.17 (-> v18.17.0) (default)
lts/* -> lts/hydrogen (-> v18.17.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.1 (-> N/A)
lts/hydrogen -> v18.17.0

This shows the currently active version on the first line (-> v18.17.0), followed by some named aliases and the versions that those aliases point to.

Conclusion

Finally Congratulations! You’ve install Node.js with a few ways on your Rocky Linux 9. Thus you’re now ready to develop and deploy powerful web applications using Node.js. First thing to remember this installation provides a solid foundation for creating high-performance websites, and you’re well on your way to leveraging the capabilities of this powerful runtime. Happy coding!

Also Read Our Other Guides :

  • How To Install Node.js on Ubuntu 22.04 With 3 Different Ways
  • How To Install and Setup Node.js on Debian 11
  • How To Use Git Version Control on Linux: For Beginner
  • How To Install and Config Git on Ubuntu 22.04
  • How To Install Jenkins on Ubuntu 22.04
  • How To Install Python 3.11 from Source on Ubuntu 22.04

As I have shown, now you have learned how to install Node.js on Rocky Linux 9 With 3 Different Ways.

TAGGED:ApplicationJavaJavascriptNodeJSProgramming LanguageRocky Linux

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Use Git Version Control on Linux: For Beginner
Next Article Initial Setup Rocky Linux 9 Server: Secure and Efficient
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

Ubuntu

How To Install PHP 8.2 on Ubuntu Server 22.04

11 Min Read
Rocky Linux

How To Secure SSH with Fail2Ban on Rocky Linux 9

12 Min Read
Rocky Linux

How To Install and Configure Apache on Rocky Linux 9

11 Min Read
Ubuntu

How To Install VirtualBox 7.0 on Ubuntu 22.04

9 Min Read
Ubuntu

How To Install Snipe-IT Asset Management on Ubuntu 22.04

13 Min Read
Rocky Linux

How To Install Rocky Linux 9.2 Server with Screenshots

12 Min Read
Rocky Linux

How To Install Docker CE on Rocky Linux 9

14 Min Read
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

17 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?