Install Node.js on Linux
There are a lot of Linux distros. Here are the three setups that cover most of them: Ubuntu/Debian, Fedora/RHEL and Arch.
Ubuntu / Debian (NodeSource recommended)
bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejsFedora / RHEL
bash
sudo dnf install -y nodejs npmArch Linux
bash
sudo pacman -S --noconfirm nodejs npmTroubleshooting
1) Permission errors on npm global installs
Don't reach for sudo npm -g every time. The more robust fix is nvm, which manages Node versions and the global package directory for you.
2) npm downloads are slow (optional)
If npm downloads crawl on your network, you can switch to a mirror registry (and switch back any time):
bash
npm config set registry https://registry.npmmirror.comCheck that it took effect:
bash
npm config get registry