Node.js 22 LTS (codenamed “Jod”) is the current long-term support release, backed by maintenance updates through April 2027. If you are running RHEL 10, Rocky Linux 10, AlmaLinux 10, or Fedora, this guide walks you through three reliable methods to get Node.js 22 installed and running in production.

Why Node.js 22 LTS?

Node.js 22 LTS brings meaningful improvements over earlier releases:

  • V8 engine 12.4 – faster JavaScript execution and lower memory overhead
  • Native WebSocket client – no external libraries needed for WebSocket connections
  • Stable watch mode – built-in file watcher restarts your app on code changes
  • require() for ESM – load ES modules from CommonJS without workarounds
  • Improved test runner – native testing with glob pattern support and code coverage
  • LTS support through April 2027 – security patches and stability fixes for production workloads

Prerequisites

Before you begin, confirm the following:

  • A running instance of RHEL 10, Rocky Linux 10, AlmaLinux 10, or Fedora (37+)
  • A user account with sudo privileges or direct root access
  • An active internet connection for downloading packages
  • System packages up to date

Start by updating your system packages:

sudo dnf update -y

Confirm your OS release:

cat /etc/redhat-release

Method 1 – Install Node.js 22 Using DNF Module Streams

RHEL 10 and its derivatives ship Node.js through Application Streams (module streams in dnf). This is the simplest approach and keeps everything managed by your system package manager.

Step 1: List available Node.js module streams

Check which Node.js versions are available in your repositories:

sudo dnf module list nodejs

You should see output listing streams such as 18, 20, and 22. Look for the nodejs:22 stream.

Step 2: Enable and install the Node.js 22 stream

Enable the Node.js 22 module stream and install it:

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

This pulls in node, npm, and their dependencies from the distribution repositories.

Step 3: Verify the installation

node -v
npm -v

Expected output:

v22.x.x
10.x.x

If you previously had a different Node.js stream enabled, reset it first:

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

Method 2 – Install Node.js 22 from NodeSource Repository

The NodeSource repository provides the latest upstream Node.js builds. This method gives you newer patch releases faster than distribution repositories.

Step 1: Add the NodeSource repository

Run the NodeSource setup script for Node.js 22:

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

This script configures the NodeSource yum/dnf repository and imports the GPG signing key.

Step 2: Install Node.js

sudo dnf install nodejs -y

Step 3: Verify the installation

node -v
npm -v

You should see output showing Node.js 22.x and npm 10.x.

Note: If you have the default AppStream Node.js package installed, remove it first to avoid conflicts:

sudo dnf remove nodejs npm -y
sudo dnf clean all

Then re-run the NodeSource setup and install commands above.

Method 3 – Install Node.js 22 Using NVM (Node Version Manager)

NVM lets you install and switch between multiple Node.js versions per user. This is ideal for development workstations or CI/CD environments where you need to test against several Node.js releases.

Step 1: Install build dependencies

sudo dnf install -y curl gcc-c++ make

Step 2: Download and run the NVM installer

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

After the script finishes, load NVM into your current shell session:

source ~/.bashrc

Confirm NVM is available:

nvm --version

Step 3: Install Node.js 22 LTS

nvm install 22

Set Node.js 22 as the default version:

nvm alias default 22
nvm use 22

Step 4: Verify the installation

node -v
npm -v
which node

The which node output should point to a path under ~/.nvm/versions/node/, confirming that NVM is managing the binary.

To list all Node.js versions installed through NVM:

nvm ls

Install Yarn as an Alternative Package Manager

Yarn is a popular alternative to npm that offers faster dependency resolution and deterministic installs through its lockfile. You can install it globally using npm:

npm install -g yarn

Verify the installation:

yarn --version

Alternatively, Node.js 22 ships with Corepack, which can manage Yarn without a separate global install:

corepack enable
corepack prepare yarn@stable --activate
yarn --version

Create a Sample Express.js Application

Let’s build a minimal Express.js web server to confirm everything works end to end.

Step 1: Set up the project directory

mkdir -p ~/myapp && cd ~/myapp
npm init -y

Step 2: Install Express

npm install express

Step 3: Create the application file

Create app.js with the following content:

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.json({
    message: 'Node.js 22 LTS is running on RHEL 10',
    nodeVersion: process.version,
    uptime: process.uptime()
  });
});

app.listen(PORT, () => {
  console.log(`Server listening on port ${PORT}`);
});

Step 4: Start the application

node app.js

Open a second terminal and test the response:

curl http://localhost:3000

You should see a JSON response confirming the Node.js version and server uptime.

Configure Node.js App as a Systemd Service

Running your application as a systemd service ensures it starts automatically on boot and restarts on failure.

Step 1: Create a dedicated system user

sudo useradd -r -s /sbin/nologin nodeapp

Step 2: Copy the application to a production path

sudo mkdir -p /opt/myapp
sudo cp -r ~/myapp/* /opt/myapp/
sudo chown -R nodeapp:nodeapp /opt/myapp

Step 3: Create the systemd unit file

Create /etc/systemd/system/myapp.service:

[Unit]
Description=Node.js Express Application
After=network.target

[Service]
Type=simple
User=nodeapp
Group=nodeapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node app.js
Restart=on-failure
RestartSec=10
Environment=NODE_ENV=production
Environment=PORT=3000

[Install]
WantedBy=multi-user.target

Note: If you installed Node.js through NVM, replace /usr/bin/node with the full path from which node (for example, /home/youruser/.nvm/versions/node/v22.x.x/bin/node).

Step 4: Enable and start the service

sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service

Step 5: Verify the service is running

sudo systemctl status myapp.service

Look for Active: active (running) in the output. Test the endpoint:

curl http://localhost:3000

To view application logs:

sudo journalctl -u myapp.service -f

PM2 Process Manager Setup

PM2 is a production-grade process manager for Node.js that handles log management, clustering, zero-downtime reloads, and monitoring – all without writing systemd unit files by hand.

Step 1: Install PM2 globally

sudo npm install -g pm2

Step 2: Start your application with PM2

cd /opt/myapp
pm2 start app.js --name myapp

Verify the process is running:

pm2 status

Step 3: Enable PM2 to start on boot

pm2 startup systemd
pm2 save

The pm2 startup command prints a systemd command you need to run with sudo. Copy and execute it.

Step 4: Useful PM2 commands

# View real-time logs
pm2 logs myapp

# Monitor CPU and memory
pm2 monit

# Restart the application
pm2 restart myapp

# Stop the application
pm2 stop myapp

# Run in cluster mode with 4 instances
pm2 start app.js -i 4 --name myapp-cluster

Open Firewall Port for Web Server

If your Node.js application serves HTTP traffic and you are running firewalld, open the port so external clients can connect.

Open port 3000 (or your application port)

sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --reload

Verify the rule is active:

sudo firewall-cmd --list-ports

You should see 3000/tcp in the output.

For production deployments, a better approach is to run Node.js behind a reverse proxy such as Nginx or HAProxy on port 80/443 and keep the Node.js port closed to external traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Troubleshooting

Module stream conflict – “nodejs” is already enabled

If you see an error about a conflicting module stream when switching from an older Node.js version:

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

Permission errors with global npm packages

If npm install -g fails with EACCES, do not run npm as root. Instead, configure npm to use a directory in your home folder:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Alternatively, use NVM (Method 3), which avoids global permission issues entirely.

Node.js binary not found after NVM install

If node is not found after installing through NVM, your shell profile may not be loading the NVM script. Add these lines to ~/.bashrc:

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

Then reload the shell:

source ~/.bashrc
node -v

Application crashes on startup – port already in use

If your app fails with EADDRINUSE, another process is using the port. Find and stop it:

sudo ss -tlnp | grep 3000
# Note the PID, then:
sudo kill -9 <PID>

Or change your application to use a different port through the PORT environment variable.

Systemd service fails to start

Check the logs for details:

sudo journalctl -u myapp.service --no-pager -n 50

Common causes:

  • Wrong ExecStart path – verify with which node
  • Missing node_modules – run npm install in the working directory
  • Permission issues – confirm the service user owns the application directory
  • SELinux denials – check with sudo ausearch -m avc -ts recent and apply appropriate context if needed

SELinux blocking Node.js network access

On RHEL 10 with SELinux enforcing, Node.js may be denied network binding. Allow it:

sudo setsebool -P httpd_can_network_connect 1

If running on a non-standard port, you may also need:

sudo semanage port -a -t http_port_t -p tcp 3000

Wrapping Up

You now have Node.js 22 LTS running on RHEL 10, Rocky Linux 10, AlmaLinux 10, or Fedora. Whether you went with the DNF module stream for simplicity, the NodeSource repo for the latest patches, or NVM for multi-version flexibility, the result is a production-ready Node.js environment. With systemd or PM2 managing your processes, your applications will stay up through reboots and recover from crashes without manual intervention.

1 COMMENT

  1. Unfortunately, this doesn’t work:

    https://stackoverflow.com/questions/72571235/can-i-install-node-js-18-on-centos-7-and-do-i-need-python-3-install-too

    Output from your commands:

    Error: Package: 2:nodejs-18.16.0-1nodesource.x86_64 (nodesource)
    Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
    Error: Package: 2:nodejs-18.16.0-1nodesource.x86_64 (nodesource)
    Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
    Error: Package: 2:nodejs-18.16.0-1nodesource.x86_64 (nodesource)
    Requires: libm.so.6(GLIBC_2.27)(64bit)
    Error: Package: 2:nodejs-18.16.0-1nodesource.x86_64 (nodesource)
    Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
    Error: Package: 2:nodejs-18.16.0-1nodesource.x86_64 (nodesource)
    Requires: libc.so.6(GLIBC_2.28)(64bit)

LEAVE A REPLY

Please enter your comment!
Please enter your name here