If you’ve ever searched how to install Node.js on Linux and ended up with three browser tabs of conflicting advice, you’re not alone. There are a few ways to do it, and most tutorials hand you one command without telling you why. That’s a problem, because the method you pick today decides how much pain you feel six months from now.

I’ve installed Node on everything from a Raspberry Pi in my homelab to production servers running half a dozen apps. So let me save you the trial and error. We’ll cover three methods, and I’ll tell you straight up which one fits your situation. There’s one mistake I see constantly that causes those cryptic permission errors, and we’ll defuse it in section three.
Quick Answer: Which Method Should You Use?
- nvm — Best for developer machines. Switch versions per project, no
sudoneeded. - NodeSource — Best for servers, CI/CD, and containers. Lets
aptmanage Node with up-to-date versions. - Distro package manager — Only if you genuinely don’t care which version you get and want zero maintenance.
Why the Installation Method Matters More Than You Think
Here’s the thing nobody tells beginners: Ubuntu’s default apt repository ships outdated Node.js versions. Often two or three major versions behind upstream. That single fact is the root of most “my project requires Node 22 but I have Node 12” headaches.
Node.js is everywhere now. According to the 2025 Stack Overflow Developer Survey, 48.7% of developers worldwide use it, up from 40.8% the year before. It’s the most widely adopted web technology on the planet. So getting the install right is worth five minutes of reading.
Get a VPS from as low as $11/year! WOW!
Pick the wrong method and you invite two specific problems: EACCES permission errors when installing global packages, and version mismatches that break builds in confusing ways. Both are avoidable. You just have to know which path to walk.
Let me tell you how I learned this. The first time the outdated-apt problem bit me was on my homelab. I was setting up a small Next.js app, and npm kept throwing “unsupported engine” warnings. I spent 45 minutes Googling cryptic errors before I finally ran node --version and saw the truth: Ubuntu had given me Node 12. The project needed 18+. Three seconds with nvm fixed what nearly an hour of forum-diving couldn’t. I never trusted the default repo again.
Method 1: Install Node.js with nvm (Recommended for Developers)
If you write code on this machine, use nvm (Node Version Manager). It installs Node entirely inside your home directory, so you never touch sudo, and you can flip between Node versions per project. This is my daily driver on every dev box I own.
Step 1: Install nvm
Grab the install script with curl. Check the nvm official repository for the latest version number, then run:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
This drops everything into ~/.nvm. Nothing goes into system directories. That’s the whole reason it sidesteps permission errors.
Step 2: Source your shell profile
The installer adds a few lines to your shell config, but your current session doesn’t know about them yet. Reload it:
source ~/.bashrc # or ~/.zshrc if you use zsh
Or just close the terminal and open a fresh one. Either works. If you live in your shell, it’s worth setting up a few bash aliases for your common nvm and npm commands later.
Step 3: Install Node.js LTS
Now install the current Long Term Support release:
nvm install --lts
As of 2026 that pulls Node 24, codenamed “Krypton.” LTS releases are the boring, stable ones you want for real work. Save the bleeding-edge builds for when you’re feeling brave.
Step 4: Set a default Node version
Tell nvm which version to load in every new shell, otherwise you’ll open a terminal and find no Node at all:
nvm alias default lts/*
Bonus: Per-project version control with .nvmrc
This is the trick competitors never mention, and it’s pure gold for teams. Drop a .nvmrc file in your project root:
echo 'lts/*' > .nvmrc
Now anyone who clones the repo can run nvm use in that folder and instantly land on the right Node version. No more “works on my machine” arguments. Pair it with Git on Linux and your whole team stays in sync. You can even automate the switch with a shell hook if you write a little bash script.
“npm recommends using a Node version manager like nvm to avoid EACCES errors entirely. When nvm installs Node, it places everything inside your home directory — a location your user owns by default.” — npm Official Documentation
That quote is the whole argument in two sentences. nvm doesn’t need root because it never writes anywhere root owns.
Method 2: Install Node.js via NodeSource (Recommended for Servers)
On servers, CI/CD runners, and containers, you usually want apt to manage Node like any other system package, but with current versions. That’s exactly what NodeSource gives you. It’s my go-to for anything headless.
Add the NodeSource repository
Run their setup script. It registers the repo and, as of the 2025/2026 update, stores GPG keys properly in /etc/apt/keyrings instead of the deprecated apt-key approach:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
Install Node.js with apt
Now it’s a normal package install:
sudo apt install -y nodejs
NodeSource bundles npm with Node, so there’s no separate install step. It supports Ubuntu, Debian, and RHEL-based distros. In 2026 you can pull Node 24.x (current LTS), 22.x, or 20.x by swapping the version in the setup URL.
Verify and test
Confirm both binaries landed:
node --version
npm --version
Heads up: Once Node is on your server, you’ll probably want to run Node.js apps in Docker for clean, reproducible deploys. For anything with a database and a cache, Docker Compose for multi-container Node.js apps keeps the whole stack in one file.
Method 3: Install Node.js from Your Package Manager
The simplest route is your distro’s own package manager. Quick, requires no extra repos, and the system updater keeps it patched. The catch is version lag, which I’ll hammer on in a second.
Ubuntu and Debian
sudo apt install nodejs npm
RHEL, Fedora, Rocky Linux, and AlmaLinux
sudo dnf install nodejs
Arch Linux and Manjaro
sudo pacman -S nodejs npm
I run Arch on my main rig (yes, btw), and its repos stay refreshingly current. Debian and Ubuntu are the worst offenders for stale versions. Their packages routinely lag two to three major versions behind upstream. Use the distro package only when the exact version genuinely doesn’t matter and you want zero maintenance overhead. For everything else, scroll back up to Method 1 or 2.
Verify Your Installation and Run a Quick Test
No matter which method you used, confirm it actually worked. First, check the versions:
node --version
npm --version
Then make sure you’re running the binary you think you are. This one catches a lot of people:
which node
Now let’s prove Node can actually do something. Create a tiny web server in a file called server.js:
const http = require('http');
const server = http.createServer((req, res) => res.end('Hello from Node!'));
server.listen(3000, () => console.log('Running on port 3000'));
Run it with node server.js and visit localhost:3000. If you’re testing on a remote box, you may need to configure UFW firewall to open port 3000 first. Finally, confirm npm works by spinning up a throwaway project:
npm init -y
npm install lodash
If that installs without complaint, you’re in business.
Common Node.js Installation Problems (and How to Fix Them)
Here’s where most of those frantic late-night searches come from. Remember the mistake I teased back in the intro? This is it.
EACCES: Permission denied when installing global packages
This is the big one. It happens when npm tries to write a global package into /usr/local/lib/node_modules, a directory owned by root. The instinct is to reach for sudo npm install -g. Don’t. That introduces long-term ownership and security headaches that are miserable to unwind later.
The clean fix is to switch to nvm (Method 1), which keeps everything in your home directory. If you can’t, configure npm to use a user-owned prefix directory instead. The npm’s official guidance on EACCES errors walks through both options in detail.
node: command not found after installation
Nine times out of ten this means you installed nvm but never reloaded your shell. Run source ~/.bashrc or open a new terminal. The install script added the right lines to your profile, but your current session hasn’t read them yet.
Wrong Node.js version showing up
If node --version reports something unexpected, a system-installed Node is probably shadowing your nvm one. Check your PATH order:
echo $PATH
The nvm path should appear before /usr/bin. If it doesn’t, that’s a Linux environment variables ordering issue. To force a specific version in your current session, just run nvm use 24 (or whatever you need). And again, which node tells you exactly which binary is active.
Keeping Node.js Up to Date
Installing Node is a one-time thing. Keeping it current is the ongoing habit that saves you from surprise breakage.
If you used nvm, upgrading is two commands:
nvm install --lts
nvm alias default lts/*
If you went the NodeSource or apt route, fold it into your normal system updates:
sudo apt update && sudo apt upgrade nodejs
Keep an eye on the lifecycle too. You can check the full Node.js LTS release schedule anytime. As of 2026, Node 24 (“Krypton”) is the active LTS and supported until roughly April 2028. Node 22 (“Jod”) is in maintenance LTS, expiring April 2026 — so if you’re still on it, now’s the time to bump up.
Where to Go From Here
That’s the whole picture: nvm for your dev machine, NodeSource for servers, distro packages only when the version doesn’t matter. Pick based on the job, sidestep the sudo npm trap, and you’ll dodge the errors that send most people to the search bar.
Once Node is humming, the natural next steps are putting it into production properly. Run your app as a service so it survives reboots by learning to create a systemd service, then manage it with systemctl to manage services. Most real deployments sit behind a reverse proxy, so it’s worth learning to set up Nginx as a reverse proxy (or the Apache web server if that’s more your style). And when your app needs to store data, pairing it with MySQL on Linux is the classic combo.
Got Node installed and want to keep leveling up your Linux skills? Browse more hands-on guides right here on the blog — I publish new ones regularly, and there’s always another tool worth mastering.




