Learning how to install Node.js on CentOS 7 is a key skill for developers, DevOps engineers, and system admins in 2025–2026 — Node.js powers scalable backends, APIs, real-time apps, microservices, serverless functions, and full-stack JavaScript projects (Express, NestJS, Next.js APIs). CentOS 7 remains widely used in legacy production servers, enterprise environments, and long-term deployments, so this guide covers four reliable methods to install Node.js:
- Compile from source — Full control, latest features
- Binary package from Node.js site — Fast pre-built install
- EPEL repository — Stable via yum (v10.x or updated)
- nvm (Node Version Manager) — Multiple versions side-by-side (best for developers)
You’ll also verify installation, test with a simple script, install npm, upgrade, and learn to uninstall cleanly.
Prerequisites
- CentOS 7 server or desktop (minimal or full install)
- Non-root user with sudo privileges (see CentOS Initial Server Setup Guide)
- Terminal access (SSH or local)
- Internet connection
Method 1: Install Node.js on CentOS 7 from Source (Full Control)
This compiles the latest version directly — great for custom builds.
- Install build dependencies
sudo yum groupinstall "Development Tools" -y
sudo yum install gcc-c++ openssl-devel -y
2. Download latest source (check https://nodejs.org/en/download for newest)
cd ~
wget https://nodejs.org/dist/v20.17.0/node-v20.17.0.tar.gz
tar xzvf node-v*.tar.gz
cd node-v*
3. Configure & compile
./configure
make -j4 # -j4 uses 4 CPU cores – adjust to your CPU
sudo make install
4. Verify
node -v # e.g., v20.17.0
npm -v # e.g., 10.8.x
Success! You now have the latest Node.js on CentOS 7 from source.
Method 2: Install Node.js on CentOS 7 Using Binary Package (Fastest Pre-built)
Download pre-compiled binaries — no compilation needed.
- Download latest binary (check https://nodejs.org/en/download for newest 64-bit Linux tar.gz)
cd ~
wget https://nodejs.org/dist/v20.17.0/node-v20.17.0-linux-x64.tar.gz
3. Extract to /usr/local
sudo tar --strip-components 1 -xzvf node-v*.tar.gz -C /usr/local
4. Verify
node -v
npm -v
Done! Fastest way to get modern Node.js on CentOS 7.
Method 3: Install Node.js on CentOS 7 Using EPEL Repository (Stable via yum)
EPEL provides Node.js (v10.x or newer via updates) — good for basic stability.
- Install EPEL repository
sudo yum install epel-release -y
2. Install Node.js
sudo yum install nodejs -y
3. Verify
node -v # e.g., v10.24.0
npm -v
Warning: EPEL’s Node.js on CentOS 7 is old (v10.x) and unsupported in 2025–2026 — use Method 1, 2, or 4 for production.
Method 4: Install Node.js on CentOS 7 Using nvm (Best for Developers)
nvm lets you switch versions instantly — perfect for legacy code, testing, or multiple projects.
- Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Close & reopen terminal (or run):
source ~/.bash_profile
2. Install latest LTS
nvm install --lts
nvm use --lts
nvm alias default lts/*
Or specific version:
nvm install 20
nvm use 20
3.Verify
node -v
npm -v
Switch anytime:
nvm install 18
nvm use 18
nvm ls
nvm ls-remote
Step 5 – Test Your Node.js Installation
Create a test file:
nano hello.js
Paste:
console.log("Hello from Node.js on CentOS 7!");
console.log("Node version:", process.version);
console.log("Platform:", process.platform);
Save & exit (Ctrl+O → Enter → Ctrl+X).
Run:
node hello.js
Output example:
Hello from Node.js on CentOS 7!
Node version: v20.17.0
Platform: linux
Success!
Step 6 – Upgrade, Uninstall & Troubleshooting
Upgrade Node.js
- Source/binary: Re-download & re-install
- EPEL: sudo yum update nodejs
- nvm: nvm install node –reinstall-packages-from=current
Uninstall Node.js
- Source/binary: sudo rm -rf /usr/local/{bin/node,bin/npm,lib/node_modules,share/man/*/node.*}
- EPEL: sudo yum remove nodejs npm
- nvm: nvm uninstall <version>
Common Issues on CentOS 7
- gcc-c++ not found → Run sudo yum groupinstall “Development Tools”
- npm permission errors → Fix global installs:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
Add to ~/.bash_profile and source ~/.bash_profile.
- Old Node version → Use NodeSource PPA or nvm for latest
How to Install Node.js on CentOS 7 – FAQ (2025–2026)
- How do I install Node.js on CentOS 7?
Best: nvm or binary package → download latest from nodejs.org - What’s the latest Node.js LTS in 2025–2026?
v20 or v22 — nvm or binary install gives you the latest on CentOS 7 - How do I use multiple Node.js versions on CentOS 7?
Use nvm: nvm install 18, nvm install 20, nvm use 20 - Is npm included with Node.js?
Yes — in binary/nvm installs; separate package in EPEL - How do I update Node.js on CentOS 7?
nvm: nvm install node –reinstall-packages-from=current Binary: Re-download & extract new version
Summary
You now know exactly how to install Node.js on CentOS 7: source compile, binary package, EPEL repo (stable but old), and nvm for version control — plus verification, first script, npm, and troubleshooting.
Mastering how to install Node.js on CentOS 7 unlocks full-stack JavaScript, APIs, web servers, automation, and modern development workflows.