JavaScript applications need a runtime and package manager, supplied together by Node.js and npm. An available AppStream module installs both on supported RHEL or CentOS Stream releases that provide modular packages, keeping them under DNF control.

The module method applies to RHEL 8, RHEL 9, and CentOS Stream 9 when the required stream is available. RHEL 10 and CentOS Stream 10 use non-modular packages, even though they still have an AppStream repository. CentOS 7 has no AppStream modules and reached end of life in June 2024; a supported operating system is the starting point for a new installation.

The distribution's BaseOS and AppStream repositories must be enabled, with sudo access for package changes. A selected stream installs Node.js and npm from the same vendor repository set. NodeSource is a separate choice when distribution streams do not provide the release line required by the application.

Steps to install Node.js with DNF modules on RHEL or CentOS Stream:

  1. List the available Node.js AppStream streams.
    $ sudo dnf module list nodejs
    ##### snipped #####
    CentOS Stream 9 - AppStream
    Name   Stream Profiles                              Summary
    nodejs 18     common [d], development, minimal, s2i Javascript runtime
    nodejs 20     common [d], development, minimal, s2i Javascript runtime
    nodejs 22     common [d], development, minimal, s2i Javascript runtime
    nodejs 24     common [d], development, minimal, s2i Javascript runtime
    nodejs 26     common [d], development, minimal, s2i Javascript runtime
    
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

    The list shown is from CentOS Stream 9; available streams differ by release and repository updates. An empty list means this module installation path is unavailable with the current repositories.

    A stream marked [e] is already enabled. Keep it unless a move to another Node.js version is planned for the applications using it. Only if nothing uses it, clear it with sudo dnf module reset –assumeyes nodejs, because a different stream cannot be enabled until then. A reset does not remove or migrate installed packages.

  2. Enable the Node.js stream required by the application.
    $ sudo dnf module enable --assumeyes nodejs:24
    ##### snipped #####
    Dependencies resolved.
    ================================================================================
     Package           Architecture     Version             Repository         Size
    ================================================================================
    Enabling module streams:
     nodejs                             24
    
    Transaction Summary
    ================================================================================
    
    Complete!

    If a different supported stream is needed, replace 24 with its number from the module list.

  3. Install Node.js and npm from AppStream.
    $ sudo dnf install --assumeyes nodejs npm
    ##### snipped #####
    Dependencies resolved.
    ============================================================================================
     Package            Arch     Version                                        Repo        Size
    ============================================================================================
    Installing:
     nodejs             aarch64  1:24.19.0-1.module_el9+1429+18202eeb           appstream   69 k
     npm                noarch   1:11.17.0-1.24.19.0.1.module_el9+1429+18202eeb appstream  2.6 M
    Installing dependencies:
     nodejs-libs        aarch64  1:24.19.0-1.module_el9+1429+18202eeb           appstream   23 M
    ##### snipped #####
    Complete!
  4. Check the installed Node.js version.
    $ node --version
    v24.19.0
  5. Check the installed npm version.
    $ npm --version
    11.17.0
  6. Run a Node.js smoke test.
    $ node --eval "console.log(1 + 2)"
    3
Share this guide