Picking a Node.js Major Version on Rocky Linux Without Rebuilding the OS
On Rocky Linux 8 and 9, DNF module streams let you pin a major version like Node.js 18 from AppStream instead of adding third-party repos. Choose the stream first, install, and verify.
22 Jul 2025, 06:40 UTC

You need Node.js 18 for a new service but the same Rocky Linux host still runs a legacy app that requires Node.js 14. Rebuilding the server or adding an unvetted third-party repo is a risk. On Rocky Linux 8 and 9 the practical lever is DNF module streams, which let you select a major version of a modular package from AppStream and keep the rest of the system on the base RHEL-compatible packages.
The takeaway is simple: choose the stream first, then install. The stream pins the major version and its dependency set, so you avoid mixing incompatible libraries from different releases.
What a module stream actually controls
Rocky Linux mirrors RHEL AppStream. A module is a named collection of related packages, e.g., nodejs or postgresql. A stream is a specific major version line within that module, e.g., nodejs:18 or postgresql:15.
Only one stream per module can be enabled at a time on a given system. Enabling a stream makes the packages from that stream available to DNF and marks the module as active. Disabling a stream removes it from the active set.
This is not parallel installs of the same package on one host. It is version selection with dependency isolation. That isolation is the benefit and the limitation.
Inspecting what is available
Run on the Rocky host as root or with sudo:
sudo dnf module list nodejsThis lists available streams, their profiles, and whether a stream is enabled, disabled, or default. The output shows the stream name and a short status column you can use to confirm the current choice before making changes.
For a broader view:
sudo dnf module listUse this to verify that no other module is already enabled that could conflict with the packages you plan to install.
Enabling a stream and installing from it
Enable the desired stream before installing the package. The operation requires root permissions and changes module state.
sudo dnf module enable nodejs:18After enabling, install the package from that stream:
sudo dnf install nodejsDNF now resolves dependencies from the nodejs:18 stream and its profile. Keep all related packages, such as npm that ships with the module, inside the same stream. Mixing packages from different streams is a common source of dependency conflicts.
Verify the selection with:
node --versionCheck the module state again:
sudo dnf module list nodejsThe enabled marker should show the chosen stream.
Switching streams safely
Changing a major version is a state-changing operation. The safe sequence is disable the current stream, enable the target stream, then reinstall or update the package so DNF re-resolves from the new stream.
sudo dnf module disable nodejs:18sudo dnf module enable nodejs:14sudo dnf reinstall nodejsRisk: disabling a stream can make packages from that stream candidates for removal if they are not required by another enabled module. Review the transaction summary before confirming.
Rollback to the previous stream follows the same steps in reverse: disable the current stream, enable the prior stream, reinstall the package, and verify with dnf module list and the version check.
Trade-offs and limits
Module streams only apply to packages that ship with modular metadata in AppStream. Many third-party repositories do not provide modules, so stream selection is unavailable for those packages.
Because only one stream per module can be active, you cannot run Node.js 14 and Node.js 18 side-by-side from modules on the same host. For true side-by-side needs, use containers or version managers outside the module system.
Stay within the same stream for the whole dependency set. Pulling a library from a different stream can create unsolvable conflicts and leaves the system in a partially upgraded state.
Actionable check
Before deploying, confirm the module is enabled and the package comes from the intended stream:
- Run
sudo dnf module list nodejsand note the enabled stream. - Run
rpm -qi nodejsto see the package origin. - Run
node --versionto confirm the major version matches the stream you selected.
If the version does not match, do not proceed with the deployment. Re-evaluate the module enable step and the DNF transaction.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.