How to install latest Node.js on CentOS or Red Hat Enterprise Linux

RPM-based enterprise Linux hosts often lag the upstream Node.js release train because distribution repositories favor supported module streams. The NodeSource RPM repository gives CentOS Stream and Red Hat Enterprise Linux-compatible systems a package-managed path to the current Node.js release line when a project needs newer runtime features than the distro channel provides.

NodeSource uses a setup script to add its RPM repository and signing key, then dnf installs the packaged nodejs build like any other system package. Keeping the runtime in a package repository means future patch updates can arrive through normal dnf update maintenance instead of manual tarball replacement.

For production workloads, the RHEL-supported module stream or an LTS channel is usually the steadier default; the Current channel moves faster. A completed install leaves the NodeSource repository enabled, reports working node and npm versions, and runs a small JavaScript expression through the installed runtime.

Steps to install latest Node.js on CentOS or Red Hat Enterprise Linux:

  1. Open a terminal with sudo privileges.
  2. Install curl and the certificate bundle used to fetch the repository setup script.
    $ sudo dnf install --assumeyes curl ca-certificates
  3. Download the NodeSource Current RPM setup script.
    $ curl -fsSL https://rpm.nodesource.com/setup_current.x -o nodesource_setup.sh

    Use setup_lts.x instead when the host should track the latest Node.js LTS line rather than the faster Current line.

  4. Add the NodeSource repository.
    $ sudo bash nodesource_setup.sh
    Repository is configured and updated.
    Run 'dnf install nodejs -y' to complete the installation.
  5. Install Node.js from the NodeSource repository.
    $ sudo dnf install --assumeyes nodejs
    Dependencies resolved.
    ##### snipped #####
    Installed:
      nodejs-2:26.3.1-1nodesource
    Complete!

    The nodejs package includes npm, so a separate npm package is not needed for the standard NodeSource install.

  6. Check the installed Node.js version.
    $ node --version
    v26.3.1

    The exact version changes as NodeSource updates the Current RPM channel.

  7. Check the included npm version.
    $ npm --version
    11.16.0
  8. Run a JavaScript smoke test with the installed runtime.
    $ node -p 'process.version+" on "+process.platform'
    v26.3.1 on linux
  9. Remove the downloaded setup script.
    $ rm --force nodesource_setup.sh