How to Install NVM on Ubuntu: A Step-by-Step Guide
Node Version Manager (NVM) is a command-line tool that lets you install and switch between multiple versions of Node.js on Ubuntu. Different web projects often need different versions of Node.js to run properly, and NVM stops you from having to uninstall and reinstall software every time you switch tasks.
You can install a specific release like Node.js 20.11.0 in seconds and switch back to an older version whenever a project requires it. The tool installs directly into your user account, keeping your setup clean and safe from system-wide conflicts. You don’t need sudo for any of the steps in this guide, and nothing is installed for other users on the machine.
Run the official install script in your terminal with curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash, or use wget if curl is missing. Then run source ~/.bashrc and check with nvm –version. The script installs nvm into ~/.nvm without sudo, so no system-wide changes are made.
How to install nvm on Ubuntu Linux
As mentioned above, nvm allows you to quickly install and use different versions of Node.js via the command line. Each version lives in its own folder under your home directory, so installing a new one never overwrites an old one. You pick the active version per terminal session, and you can set a default for new sessions.
The steps below show you how to do that on Ubuntu Linux. They work on current Ubuntu releases, both desktop and server. You only need a regular user account and an internet connection.
Install nvm
You can install nvm (Node Version Manager, a tool that lets you manage multiple versions of Node.js) on Ubuntu by running a single download script in your terminal. Paste the official curl or wget command into your command line and press Enter to fetch the setup script, which automatically configures everything you need to start using nvm on your system.
To open a terminal, press Ctrl+Alt+T, or search for Terminal in the Activities overview. You only need one of the two commands below. Use whichever tool is already on your system. Wget is included with most Ubuntu installs, while curl is sometimes missing. If your terminal says a command is not found, try the other one.
cURL command:
Paste the command below into the terminal and press Enter. You should see a short download progress meter, followed by the installer’s own messages.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Wget command:
If you prefer wget, or curl isn’t installed, run the command below instead. Don’t run both. One is enough.
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Either of the commands above should download the nvm install script that can be used to install. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
On a default Ubuntu account that uses bash, the lines normally end up in ~/.bashrc. These lines are what make the nvm command available each time you open a terminal. If nvm isn’t found later, open your profile file and check that they are there.
After installing, the script should output the lines below. Seeing them means the download and the profile change both worked.
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Once downloaded, you can then activate and reload your shell environment. By default, it’s bash (~/.bashrc). Your current terminal window doesn’t know about the new profile lines yet, so without this step nvm will not be found.
- Run the command below in the same terminal window.
- Wait for the prompt to return. There is normally no output.
source ~/.bashrc
To check the version of nvm installed, run the commands below. The terminal should print a version number. If it says the command is not found instead, the shell hasn’t loaded the profile changes. Reload your profile file or open a new terminal and try again.
nvm --version
Install Node.js with nvm
You can install Node.js with nvm on Ubuntu by running the nvm install command in your terminal. This downloads and sets up the latest or a specific version of Node.js for your user account without needing root permissions, letting you switch between different software versions whenever your projects require it.
The first version you install becomes the active version in that terminal automatically. npm, the Node package manager, is installed along with it. The sections below cover the latest release, the long-term support release and a specific version.
Run the commands below to download and install the current and latest version of node.js. The latest release has the newest features, but it isn’t always the one with long-term support. Pick the LTS release below if you need stability.
nvm install node
Once installed, you can check the version of node.js installed by running the commands below. The terminal should print a version number that starts with the letter v. It should match the release you just installed.
node --version
Run the commands below to install the latest stable version (long-term support). LTS releases get bug and security fixes for longer, so they are the usual choice for production work and for projects you want to leave alone for a while.
nvm install --lts
To install a specific version (12.17.0), run the commands below. Use this when a project states the exact Node.js version it needs. Version 12.17.0 is only an example, and it is old and no longer supported. For new work, choose a current LTS release and keep older versions for legacy projects. To install a different version, change the number in the command to the one you need.
nvm install 12.17.0
To list all available versions in the repository, run the commands below. The list is long, so you may need to scroll. Use it to find the exact version number to install. Releases you already have installed are marked in the list.
nvm ls-remote
If you have multiple versions of node.js installed, run the commands below to specify the version you want to use. The change applies to the current terminal session. Run the node version check again afterwards to confirm the version changed. A new terminal window starts with your default version, which the next section covers.
nvm use 12.17.0
To find the current default node.js installed, run the commands below. The default is the version a new terminal starts with, and it can differ from the version active in your current window.
nvm run default --version
Uninstall node.js
nvm won’t remove the version that is currently active. If you get an error saying so, switch to another installed version first, then run the uninstall command again. If you remove a version by mistake, you can install it again at any time with the same install steps.
nvm uninstall v12.17.0
That should do it! You now have nvm running on Ubuntu and can install, switch and remove Node.js versions as your projects need.
Conclusion:
- Nvm is a valuable tool for developers to manage multiple versions of node.js on their systems easily.
- By following the installation instructions, developers can quickly install and use different versions of node.js via the command line.
- The provided guide simplifies installing nvm on Ubuntu Linux and showcases how to install and manage node.js using nvm.
- Users are encouraged to provide feedback or suggestions for improvement through the comment section below.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!