Node.js is a JavaScript runtime built on Chrome’s V8 engine, widely used for building fast, scalable network applications, REST APIs, and real-time services. RHEL 8 provides Node.js through two channels: the built-in AppStream module system and the NodeSource third-party repository, which typically offers newer LTS releases. This tutorial covers both installation methods, verifying the installation, managing global packages, auditing for vulnerabilities, and building a minimal Express web server to confirm everything is working. Choose the method that best fits your environment and version requirements.

Prerequisites

  • RHEL 8 server with a sudo-capable user
  • Active internet connection for downloading packages
  • Basic familiarity with the Linux command line and dnf
  • Port 3000 accessible if you want to test the Express app from a browser

Step 1 — Install Node.js via AppStream Module (Method A)

The RHEL 8 AppStream module system provides curated Node.js versions that are tested against the OS. This is the recommended method for production systems that prioritize stability and Red Hat support.

# List available Node.js module streams
dnf module list nodejs

# Install Node.js 18 LTS (common profile includes npm)
sudo dnf module install -y nodejs:18/common

# Verify
node --version
npm --version

If you need to switch streams later, reset the module first: sudo dnf module reset nodejs, then install the desired version.

Step 2 — Install Node.js via NodeSource Repository (Method B)

NodeSource provides RPM packages for current and LTS Node.js releases that are often more up-to-date than AppStream. Use this method when you need Node.js 20 or later.

# Download and run the NodeSource setup script for Node.js 20
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

# Install Node.js (npm is bundled)
sudo dnf install -y nodejs

# Verify
node --version
npm --version

The setup script adds a nodesource repo file under /etc/yum.repos.d/. You can inspect it with cat /etc/yum.repos.d/nodesource*.repo before installing if you prefer to review repo configuration before running.

Step 3 — Install and Manage Global npm Packages

Global npm packages are installed system-wide and available as CLI commands. The -g flag installs to the global prefix.

# Install a package globally
sudo npm install -g nodemon

# List installed global packages
npm list -g --depth=0

# Update all global packages
sudo npm update -g

# Remove a global package
sudo npm uninstall -g nodemon

Step 4 — Audit Packages for Vulnerabilities

npm includes a built-in security audit tool that checks your project dependencies against the npm advisory database. Run it regularly as part of your development workflow.

# In your project directory — audit all dependencies
npm audit

# Automatically fix vulnerabilities where possible
npm audit fix

# Force fixes including semver-major upgrades (review changes carefully)
npm audit fix --force

Step 5 — Create a Simple Express Application

Express is the most popular Node.js web framework. Create a minimal project to confirm your Node.js installation is fully functional.

mkdir -p ~/mynode && cd ~/mynode
npm init -y
npm install express

cat > app.js < {
  res.json({ message: 'Node.js is running on RHEL 8', version: process.version });
});

app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

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

node app.js

Open another terminal and confirm the app responds:

curl http://localhost:3000/

Step 6 — Open the Firewall Port (Optional)

If you need external access to the Node.js app directly on port 3000 (before adding a reverse proxy), open the port in firewalld:

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

Conclusion

Node.js is now installed and verified on RHEL 8, with npm available for package management and security auditing. You have a working Express application as a foundation to build on. For production deployments, avoid running Node.js directly with node app.js — use a process manager like PM2 to handle restarts, clustering, and log management automatically.

Next steps: How to Manage Node.js Versions with NVM on RHEL 8, How to Deploy a Node.js Application with PM2 on RHEL 8, and Setting Up Nginx as a Reverse Proxy for Node.js on RHEL 8.