Learning how to install Node.js on Ubuntu is a must-have skill for developers, DevOps engineers, and anyone building modern web apps, APIs, microservices, or real-time applications in 2025–2026. Node.js powers the backend of millions of projects — from startups using Express/NestJS to enterprises running scalable APIs, serverless functions (Vercel, AWS Lambda), and full-stack JavaScript stacks (MERN, MEAN).
Ubuntu 18.04 (Bionic Beaver) is still widely used in production (especially legacy servers), and this guide shows you three proven methods to install Node.js:
- Default apt repositories — Fast & stable (v8.10 or newer via updates)
- NodeSource PPA — Latest LTS/current versions (recommended for most users)
- nvm (Node Version Manager) — Multiple versions side-by-side (best for developers)
You’ll also verify installation, install npm, test with a “Hello World” script, and learn to upgrade/uninstall.
Prerequisites
- Ubuntu 18.04 LTS server or desktop
- Non-root user with sudo privileges
- Terminal access (SSH or local)
- Internet connection
Method 1: Install Node.js on Ubuntu 18.04 Using Default apt (Quick & Stable)
This method uses Ubuntu’s official repositories — great for basic needs or production stability.
- Update package index
sudo apt update
2. Install Node.js
sudo apt install nodejs -y
3. Verify version
node -v
Output (typical in 18.04):
v8.10.0
4. Install npm (package manager)
sudo apt install npm -y
npm -v
Output example:
6.14.18
Done! You now have Node.js installed on Ubuntu 18.04 via apt.
Method 2: Install Latest Node.js on Ubuntu 18.04 Using NodeSource PPA (Recommended)
The default version is old (v8). NodeSource PPA gives you modern LTS (v18/v20) or current versions.
Choose your version (2025–2026 recommendations):
- LTS: setup_20.x or setup_18.x
- Current: setup_current
Example for Node 20 LTS:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
2. Install Node.js
sudo apt install nodejs -y
3. Verify
node -v # e.g., v20.17.0
npm -v # e.g., 10.8.x
Success! You now have the latest stable Node.js on Ubuntu 18.04.
Method 3: Install Node.js on Ubuntu 18.04 Using nvm (Best for Developers)
nvm lets you switch versions instantly — perfect for testing, legacy projects, or running multiple Node versions.
- Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Close & reopen terminal (or run):
source ~/.bashrc
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 # list installed versions
nvm ls-remote # see all available versions
Step 4 – Test Your Node.js Installation
Create a test file:
nano hello.js
Paste:
console.log("Hello from Node.js on Ubuntu!");
console.log("Node version:", process.version);
console.log("Platform:", process.platform);
Save & exit (Ctrl+O → Enter → Ctrl+X).
Run:
node hello.js
Output:
Hello from Node.js on Ubuntu!
Node version: v20.17.0
Platform: linux
Success!
Step 5 – Upgrade, Uninstall & Troubleshooting
Upgrade Node.js
- Apt: sudo apt update && sudo apt upgrade nodejs
- NodeSource: Re-run PPA setup script → sudo apt upgrade nodejs
- nvm: nvm install node –reinstall-packages-from=current
Uninstall Node.js
- Apt: sudo apt remove –purge nodejs npm && sudo apt autoremove
- nvm: nvm uninstall <version> (e.g., nvm uninstall 20)
Common Issues on Ubuntu 18.04
- E: Unable to locate package nodejs → Run sudo apt update first
- Permission denied on npm global installs → Fix with:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
Add to ~/.bashrc and source ~/.bashrc.
How to Install Node.js on Ubuntu – FAQ (2025–2026)
- How do I install Node.js on Ubuntu 18.04?
Best: NodeSource PPA → curl setup_20.x | sudo bash – → sudo apt install nodejs - What’s the latest Node.js LTS in 2025–2026?
v20 or v22 — use NodeSource or nvm to get it on 18.04 - How do I use multiple Node.js versions on Ubuntu?
Use nvm: nvm install 18, nvm install 20, nvm use 20 - Is npm installed with Node.js?
Yes — in NodeSource/nvm installs; separate in default apt - How do I update Node.js on Ubuntu 18.04?
NodeSource: sudo apt update && sudo apt upgrade nodejs nvm: nvm install node –reinstall-packages-from=current
Summary
You now know exactly how to install Node.js on Ubuntu 18.04: fast apt method, modern NodeSource PPA (latest versions), and nvm for version control — plus verification, first script, npm, and troubleshooting.
Mastering how to install Node.js on Ubuntu unlocks full-stack JavaScript development, APIs, web servers, automation, and more.