Guide
Using Rocky Linux Module Streams to Run Multiple Versions of Node.js
Learn how to enable, install, and switch Node.js streams on Rocky Linux 9 with dnf module commands, plus limits and common pitfalls.
Published by Tasadduq Burney
21 Jul 2025, 02:48 UTC
2 min69.5K views0

You can install and switch between different Node.js versions on a single Rocky Linux system without containers by using AppStream module streams.
Worked example: enabling and switching Node.js streams
- Check what streams are available for the nodejs module:
- Enable the desired stream, for example Node.js 18 LTS:
- Install the runtime profile (common) which pulls only the Node.js binary and core libraries:
- Verify the installed version:
- To change to a newer stream, first reset the module, then enable and install the new stream:
# Run as root or with sudo
sudo dnf module list nodejs
sudo dnf module enable nodejs:18
sudo dnf module install nodejs:18/common
node --version
# Expected output shows v18.x.x
sudo dnf module reset nodejs
sudo dnf module enable nodejs:20
sudo dnf module install nodejs:20/common
node --version # Should show v20.x.x
Limits and common mistakes
- Only one stream of a given module can be active at a time. Attempting to enable a second stream without resetting leaves the previous stream enabled but no packages installed, leading to confusion.
- Enabling a stream does not install packages; forgetting the dnf module install step leaves the system with no Node.js binaries even though the stream appears enabled.
- Switching streams on a system that already has packages from the old stream can leave orphaned RPMs. Use dnf module switch-to nodejs:20 (available on newer dnf) or the reset‑then‑install sequence to handle removal and installation atomically.
- Module streams share the host’s glibc and kernel; they do not provide the full isolation of containers. If you need a different libc or kernel version, use a container or virtual machine.
- Stream lifecycles are independent of the Rocky Linux release. For example, the Node.js 18 stream ends upstream in April 2025, while Rocky Linux 9 is supported until 2032. Plan to migrate before the stream’s end‑of‑life.
- Third‑party repositories that provide their own modulemd can conflict with the AppStream version. DNF selects the stream from the repository with the highest priority (lowest priority number). Verify priority settings in /etc/yum.repos.d/ if you see unexpected versions.
Practical verification steps
- List installed modules: sudo dnf module list --installed should show nodejs:18/common or nodejs:20/common depending on what you installed.
- Check the module metadata directly: sudo dnf repoquery --location nodejs:18 shows the RPMs pulled from the AppStream repo.
- Review the modulemd YAML if you need to audit dependencies: sudo yum install dnf-plugins-core then sudo dnf module info nodejs:18 displays profiles and dependencies.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.