How to Install Node.js on Linux: NVM, Package Managers, and NodeSource
This guide walks you through multiple ways to install Node.js on Linux—including the recommended NVM method, using distribution package managers for stable releases, and adding NodeSource repositories for the latest versions—covering version listing, switching, setting defaults, and removal, with full command examples and screenshots.
Node.js is an open‑source, cross‑platform, lightweight JavaScript runtime built on Chrome's V8 engine, used for creating scalable network applications. It includes the npm package manager, which hosts the world’s largest open‑source library ecosystem.
1. Install Node.js on Linux using NVM (recommended)
NVM (Node Version Manager) is a bash script that lets you install, uninstall, and switch between multiple Node.js versions.
Install NVM with the latest script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bashor
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bashThe script clones the repository to ~/.nvm and adds source lines to your shell profile. Restart the terminal, then verify the installation: command -v nvm Output should be nvm.
List available Node.js versions: nvm ls-remote Install the latest version: nvm install node Install a specific version (e.g., v12.20.2): nvm install v12.20.2 Show installed versions: nvm list Check the default version: node --version Check npm version: npm -v Switch between installed versions: nvm use node Or run a specific version directly: nvm run node v12.20.2 Set a version as the default: nvm alias default v12.20.2 Uninstall a version (first ensure it is not the active one): nvm uninstall v12.20.2 If the version is active, deactivate NVM first: nvm deactivate Then uninstall:
nvm uninstall nodeSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
