How to Install Node.js on Rocky Linux 10, 9 and 8

Install Node.js on Rocky Linux 10, 9 and 8 using DNF, NodeSource or NVM. Covers npm setup, module streams, version switching, removal.

UpdatedPublished AuthorJoshua JamesRead time8 minGuide typeRocky Linux

Modern JavaScript tooling moves quickly, and Rocky Linux gives you three practical paths: a system-managed Node.js package from AppStream, a DNF-managed upstream package from NodeSource, or a per-user NVM install. If you want to install Node.js on Rocky Linux for APIs, build tools, CLI utilities, or frontend frameworks, start with AppStream unless a project explicitly requires a different major version.

Rocky Linux 10 packages Node.js as a normal AppStream package, while Rocky Linux 9 and 8 use DNF module streams. NodeSource is useful when you want the current upstream LTS package managed by DNF, and NVM fits per-project version switching without changing system packages.

Install Node.js on Rocky Linux

Choose a Node.js Installation Method

Use the method that matches how you want updates and version switching to work. The package names differ by Rocky release, so the method sections keep Rocky Linux 10 separate from Rocky Linux 9 and 8.

MethodSourceVersion LineUpdatesBest For
AppStreamRocky Linux repositoriesRocky 10 ships Node.js 22; Rocky 9 and 8 offer module streamsThrough normal DNF upgradesProduction servers and simple system-wide installs
NodeSource RPM repositoryNodeSource distributionsNode.js 24 Active LTS, Node.js 22 maintenance LTS, or Node.js 26 CurrentThrough normal DNF upgrades after the repository is addedDevelopers who need a newer upstream package than AppStream provides
NVMNode Version ManagerAny supported Node.js release per user accountManual with nvm installPer-project development, testing multiple versions, and no-root installs

Node.js packaging differs across Rocky Linux releases. Rocky Linux 10 does not use Node.js module streams, while Rocky Linux 9 and 8 still use streams such as nodejs:24 and nodejs:22. Rocky Linux 8 remains supported, but its default nodejs:10 stream is obsolete for new projects.

Update Rocky Linux Before Installing Node.js

Refresh package metadata and apply available updates before installing a runtime. This reduces dependency conflicts, especially on hosts that have not been updated recently.

sudo dnf upgrade --refresh

The commands in this article use sudo for system-wide package changes. Enter your user’s password when prompted, or switch to an account that already has administrator privileges.

Install Node.js from AppStream on Rocky Linux 10

Rocky Linux 10 installs Node.js directly from AppStream. The nodejs package pulls in nodejs-npm as a weak dependency on a normal install, so npm becomes available with the runtime.

sudo dnf install nodejs

Verify both commands after the transaction finishes:

node --version
npm --version

Rocky Linux 10 currently returns a Node.js 22 line from AppStream:

v22.x.x
10.x.x

Install Node.js from AppStream on Rocky Linux 9 and 8

Rocky Linux 9 and 8 use module streams for Node.js. List the available streams first if you need to confirm what your enabled repositories provide:

dnf module list nodejs

Relevant output on current Rocky Linux 9 includes the maintained Node.js 22 and 24 streams:

Rocky Linux 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

Enable the Node.js 24 stream for the current LTS line, then install the runtime and npm package together:

sudo dnf module enable nodejs:24
sudo dnf install nodejs npm

Verify the installed runtime and npm version:

node --version
npm --version

Rocky Linux 9 and 8 currently return the Node.js 24 stream when that module is enabled:

v24.x.x
11.x.x

If a project still needs the Node.js 22 line, replace nodejs:24 with nodejs:22 in the module command. Avoid starting new work on Node.js 20 or older unless you are maintaining a legacy application with a planned upgrade path.

Compare Node.js Release Lines

The Node.js project keeps even-numbered releases on the LTS track and shortens the life of odd-numbered Current releases. For production workloads, use Active LTS or Maintenance LTS unless a framework or test matrix requires Current.

Node.js LineCodenameStatusOfficial End DateRocky Install Notes
Node.js 26None yetCurrentApril 30, 2029, after its planned LTS transitionAvailable from NodeSource as setup_26.x; use mainly for testing new platform changes
Node.js 24KryptonActive LTSApril 30, 2028Recommended LTS line for new projects; available from Rocky Linux 9 and 8 module streams, NodeSource, and NVM
Node.js 22JodMaintenance LTSApril 30, 2027Rocky Linux 10 AppStream currently ships this line; useful for conservative compatibility targets
Node.js 20IronEnd-of-lifeApril 30, 2026Do not use for new projects; keep only for legacy applications while planning migration

The official Node.js release schedule and Node.js EOL page are the best places to check lifecycle status before choosing a runtime for long-lived deployments.

Install Node.js from NodeSource on Rocky Linux

NodeSource publishes RPM repositories for RPM-based distributions. The current setup scripts write repository files under /etc/yum.repos.d/, use the shared NodeSource operations signing key, and support x86_64 and aarch64 systems.

Remove Conflicting System Node.js Packages

NodeSource installs the same node and npm commands as the Rocky packages, so remove any existing system-wide Node.js package before switching sources.

On Rocky Linux 10, remove the runtime and npm companion package:

packages=(nodejs nodejs-npm)
installed=()

for package in "${packages[@]}"; do
  if rpm -q "$package" >/dev/null 2>&1; then
    installed+=("$package")
  fi
done

if ((${#installed[@]})); then
  sudo dnf remove "${installed[@]}"
else
  echo "No system-wide Node.js packages are installed"
fi

On Rocky Linux 9 and 8, remove the module-stream packages:

packages=(nodejs npm)
installed=()

for package in "${packages[@]}"; do
  if rpm -q "$package" >/dev/null 2>&1; then
    installed+=("$package")
  fi
done

if ((${#installed[@]})); then
  sudo dnf remove "${installed[@]}"
else
  echo "No system-wide Node.js packages are installed"
fi

Add the NodeSource RPM Repository

The NodeSource setup script uses the curl command in Linux to fetch the repository installer. Check that curl is available first:

curl --version

If that command is missing, install the curl package:

sudo dnf install curl

Confirm that your system uses an architecture supported by the NodeSource RPM script:

uname -m

NodeSource supports x86_64 and aarch64 for this RPM repository family:

x86_64

Add the Node.js 24 LTS repository with the current NodeSource RPM setup script:

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

Use setup_22.x only when a project requires Node.js 22, or setup_26.x when you specifically need the short-lived Current line. Node.js 24 remains the safer default for most new deployments.

Confirm that the setup script created the expected repository files:

grep -E '^\[|^(baseurl|enabled|gpgcheck|gpgkey|module_hotfixes)=' /etc/yum.repos.d/nodesource*.repo

Relevant repository lines on x86_64 systems include the following. On aarch64 systems, the final path segment changes to aarch64.

[nodesource-nodejs]
baseurl=https://rpm.nodesource.com/pub_24.x/nodistro/nodejs/x86_64
enabled=1
gpgcheck=1
gpgkey=https://rpm.nodesource.com/gpgkey/ns-operations-public.key
module_hotfixes=1
[nodesource-nsolid]
baseurl=https://rpm.nodesource.com/pub_24.x/nodistro/nsolid/x86_64
enabled=1
gpgcheck=1
gpgkey=https://rpm.nodesource.com/gpgkey/ns-operations-public.key
module_hotfixes=1

Install the NodeSource Node.js Package

Install the NodeSource package after the repository is configured. The first install imports the NodeSource RPM signing key with fingerprint 242B 8138 31AF 0956 2B6C 46F7 6B88 DA4E 3AF2 8A14.

sudo dnf install nodejs

Verify the installed runtime. NodeSource bundles npm inside the nodejs package, so there is no separate npm RPM to install.

node --version
npm --version
rpm -q nodejs

Current NodeSource 24 output on x86_64 systems follows this pattern. On aarch64 systems, the RPM package name ends with .aarch64.

v24.x.x
11.x.x
nodejs-24.x.x-1nodesource.x86_64

Install Node.js with NVM on Rocky Linux

NVM installs Node.js under your user account and loads as a shell function. It does not change system packages, which makes it a good fit when different projects need different Node.js versions.

Install NVM for Your User

Install curl if your system does not already provide the curl command:

curl --version || sudo dnf install curl

Run the current NVM installer as your normal user, not with sudo:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

The installer writes NVM startup lines to your shell profile. Load them in the current terminal, or open a new terminal session:

source ~/.bashrc

Zsh users should run source ~/.zshrc instead. Verify that the shell function loaded correctly:

command -v nvm
nvm --version
nvm
0.40.4

Install the Latest LTS Node.js with NVM

Install the latest LTS release for your account:

nvm install --lts

NVM downloads the official Linux binary, verifies the checksum, and activates the version in your current shell. Verify Node.js and npm afterward:

node --version
npm --version
v24.x.x
11.x.x

Switch Node.js Versions with NVM

Install another major version when a project needs it, then switch your active shell to that version:

nvm install 22
nvm use 22

Set a default version for new terminal sessions:

nvm alias default 24

For project-specific version pinning, create a .nvmrc file in the project directory:

printf '%s\n' '24' > .nvmrc
nvm use

Update Node.js on Rocky Linux

Update AppStream and NodeSource installations through DNF. AppStream updates follow Rocky Linux package updates, while NodeSource updates follow the enabled NodeSource major line.

sudo dnf upgrade --refresh

For NVM, install the newer release line and switch your shell to it:

nvm install --lts
nvm alias default 'lts/*'
nvm use --lts

Troubleshoot Node.js on Rocky Linux

Node.js Module Stream Conflicts

Rocky Linux 9 and 8 can block a stream switch when another Node.js stream is already enabled. Reset the stream, then enable the line you want:

sudo dnf module reset nodejs
sudo dnf module enable nodejs:24

Install the matching packages again after the reset:

sudo dnf install nodejs npm

curl Package Conflicts on Minimal Installs

Some minimal Rocky Linux images already include curl-minimal. If installing the full curl package reports a conflict, keep the minimal package because it still provides the curl command needed by NodeSource and NVM:

sudo dnf install curl-minimal
curl --version

npm Command Not Found

If node works but npm does not, install the npm companion package for your source. Rocky Linux 9 and 8 use npm:

sudo dnf install npm

Rocky Linux 10 uses nodejs-npm when weak dependencies were skipped:

sudo dnf install nodejs-npm

NodeSource and NVM installations bundle npm with the selected Node.js release, so a missing npm command there usually means the active shell is not using that install path.

NVM Command Not Found

NVM loads as a shell function, so which nvm is not a reliable check. Use command -v nvm after loading your shell profile:

source ~/.bashrc
command -v nvm

If the command still prints nothing, confirm that the NVM startup lines exist:

grep -E 'NVM_DIR|nvm.sh|bash_completion' ~/.bashrc

Expected lines look similar to this:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

For zsh, repeat the same check against ~/.zshrc.

npm Permission Errors

Global npm installs from a DNF-managed Node.js package can fail when npm tries to write under a root-owned prefix. Check the prefix first:

npm config get prefix

If the prefix is a system path such as /usr, use a user-owned global directory:

mkdir -p ~/.npm-global
npm config set prefix "$HOME/.npm-global"
printf '%s\n' 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Skip this prefix change when you use NVM. NVM already keeps global packages inside the active Node.js version under ~/.nvm, and a custom npm prefix can prevent NVM from switching versions cleanly.

If you already set a custom npm prefix and later switch to NVM, remove that prefix before loading NVM again:

npm config delete prefix
unset PREFIX NPM_CONFIG_PREFIX npm_config_prefix
source ~/.bashrc

Zsh users should source ~/.zshrc instead.

npm Install Fails with Git Errors

Some npm packages fetch dependencies from Git repositories during installation. If npm reports a missing git command or fails while cloning a dependency, install Git on Rocky Linux, then rerun the npm command.

Remove Node.js from Rocky Linux

Use the removal path that matches your install method. Avoid running a broad dnf autoremove as a blind cleanup step, because reused systems can have unrelated packages marked as removable.

Remove AppStream Node.js

On Rocky Linux 10, remove Node.js and npm, then verify the packages are gone:

sudo dnf remove nodejs nodejs-npm
rpm -q nodejs nodejs-npm || true

A removed package check reports:

package nodejs is not installed
package nodejs-npm is not installed

On Rocky Linux 9 and 8, remove the module-stream packages and reset the stream:

sudo dnf remove nodejs npm
sudo dnf module reset nodejs
rpm -q nodejs npm || true

Remove NodeSource Node.js

Remove the NodeSource package, then delete the repository files created by the setup script:

sudo dnf remove nodejs
sudo rm -f /etc/yum.repos.d/nodesource-nodejs.repo /etc/yum.repos.d/nodesource-nsolid.repo
sudo dnf clean all
rpm -q nodejs || true

If no other NodeSource repository remains on the system, remove the imported NodeSource RPM signing key:

mapfile -t nodesource_keys < <(rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' | grep -i 'gpg-pubkey-3af28a14-' || true)

if ((${#nodesource_keys[@]})); then
  sudo rpm -e "${nodesource_keys[@]}"
else
  echo "NodeSource RPM key is not installed"
fi

Remove NVM and User-Installed Node.js

The next commands permanently delete NVM-managed Node.js versions and the npm cache for your user account. Back up project files and any global packages you still need before removing ~/.nvm or ~/.npm.

command -v nvm > /dev/null && nvm deactivate || true
command -v nvm > /dev/null && nvm unload || true
rm -rf ~/.nvm ~/.npm

Remove the NVM startup lines from Bash and zsh profile files. The command creates a backup next to each edited profile first:

for profile in ~/.bashrc ~/.zshrc; do
  [ -f "$profile" ] || continue
  cp "$profile" "$profile.nvm-backup"
  sed -i \
    -e '/^export NVM_DIR=.*\.nvm/d' \
    -e '/\$NVM_DIR\/nvm\.sh/d' \
    -e '/\$NVM_DIR\/bash_completion/d' \
    "$profile"
done

Open a new terminal, then verify the NVM function is gone. If a system or NodeSource package is still installed, node --version can still return that system-managed runtime.

command -v nvm || echo "nvm is not loaded"
node --version 2>/dev/null || echo "node is not available from the current PATH"

Conclusion

Node.js is ready on Rocky Linux with a package source that matches your workflow: AppStream for conservative system-managed deployments, NodeSource for current upstream LTS packages, or NVM for per-project version control. A code editor such as VS Code on Rocky Linux pairs well with the runtime when you start building and debugging projects.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: