Node.js 22 is the current Long-Term Support release, receiving security patches and bug fixes through April 2027. Fedora ships Node.js in its default repositories, but those builds can lag behind or jump ahead depending on the Fedora release cycle. This guide covers two reliable ways to get Node.js 22 LTS on Fedora 42, 41, and 40 – the Fedora DNF module system and the NodeSource third-party repository.

Prerequisites

  • Fedora 42, 41, or 40 workstation or server
  • A user account with sudo privileges
  • A working internet connection

Check Current Node.js Status

Before installing, check whether an older version is already present:

node -v
npm -v

If you see a version you want to replace, remove it first to avoid conflicts:

sudo dnf remove nodejs npm -y

Method 1 – Install Node.js 22 via Fedora DNF Module

Fedora uses modular repositories that allow you to pick a specific version stream of a package. This is the cleanest approach because the packages are built and tested by Fedora maintainers.

List Available Node.js Streams

Check which Node.js module streams are available on your system:

sudo dnf module list nodejs

You should see output listing streams like 18, 20, and 22. The stream marked with [d] is the default.

Reset Any Existing Module Stream

If a different stream was previously enabled, reset it:

sudo dnf module reset nodejs -y

Enable and Install the Node.js 22 Stream

Enable the version 22 stream and install Node.js in one step:

sudo dnf module enable nodejs:22 -y
sudo dnf install nodejs -y

This pulls in both the nodejs binary and npm from the Fedora 22 stream.

Verify the Installation

node -v
npm -v

You should see Node.js v22.x.x and a corresponding npm version.

Method 2 – Install Node.js 22 via NodeSource Repository

NodeSource maintains up-to-date RPM packages for Node.js LTS releases. This method is useful when the Fedora module stream has not yet caught up to the latest patch level, or when you want Node.js builds that closely mirror the upstream release schedule.

Add the NodeSource Repository

NodeSource provides a setup script that configures the DNF repository. Run it with the major version you want:

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

The script adds the NodeSource repository file under /etc/yum.repos.d/ and imports the signing key.

Install Node.js

sudo dnf install nodejs -y

NodeSource packages bundle npm inside the nodejs package, so no separate npm install is needed.

Verify the Installation

node -v
npm -v

Confirm the versions match what NodeSource advertises for the 22.x LTS branch.

Install Development Tools (Optional)

Some npm packages include native C/C++ addons that need to be compiled during installation. Install the build toolchain so those packages work without errors:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install gcc-c++ make python3 -y

Verify gcc is available:

gcc --version

Install Yarn Package Manager (Optional)

If your project uses Yarn instead of npm, enable it through Corepack, which ships with Node.js 22:

sudo corepack enable
yarn --version

Corepack manages Yarn and pnpm versions automatically based on the packageManager field in your project’s package.json.

Test Node.js with a Simple HTTP Server

Create a quick test to make sure the runtime works correctly:

cat <<'EOF' > /tmp/test-server.js
const http = require('http');
const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Node.js 22 LTS is running on Fedora\n');
});
server.listen(3000, () => {
  console.log('Server running at http://localhost:3000/');
});
EOF

node /tmp/test-server.js

Open a second terminal and test with curl:

curl http://localhost:3000

You should see: Node.js 22 LTS is running on Fedora

Managing Multiple Node.js Versions with NVM

If you work on projects that target different Node.js versions, consider using NVM (Node Version Manager) instead of system packages. NVM installs Node.js under your home directory and lets you switch versions per-shell:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use 22
node -v

NVM is a per-user tool and does not conflict with system-level Node.js packages.

Switching Between DNF Module and NodeSource

If you installed via NodeSource and want to switch back to Fedora’s module stream (or the other way around), fully remove the current install first:

sudo dnf remove nodejs -y
sudo dnf module reset nodejs -y

If switching away from NodeSource, also remove the repository:

sudo rm -f /etc/yum.repos.d/nodesource*.repo
sudo dnf clean all

Then follow the appropriate method above for a clean install.

Wrapping Up

You now have Node.js 22 LTS running on Fedora. The DNF module method is the most “Fedora-native” approach and integrates cleanly with system updates. NodeSource is a solid alternative when you need the absolute latest patch release or a version stream that Fedora’s modules do not yet offer. For development workstations where you juggle multiple Node.js versions, NVM gives you the most flexibility without touching system packages.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here