How to nvm install
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- nvm allows you to manage multiple Node.js versions on a single machine.
- The installation script is usually downloaded using `curl` or `wget`.
- After installation, you must restart your terminal or source your profile.
- Common nvm commands include `nvm install <version>`, `nvm use <version>`, and `nvm ls`.
- nvm is primarily used for Unix-like operating systems (macOS, Linux, WSL).
What is nvm?
Node Version Manager (nvm) is a powerful command-line tool that enables you to install, manage, and switch between different Node.js versions on your system. This is incredibly useful for developers who work on projects that may require specific Node.js versions or who want to test their applications with multiple Node.js environments.
Why Use nvm?
In the world of software development, dependencies are key. Different projects might rely on specific versions of Node.js to function correctly. Without a version manager like nvm, managing these different versions can become a cumbersome task involving manual installations and potential conflicts. nvm simplifies this process significantly, allowing you to:
- Install any Node.js version with a single command.
- Switch between installed versions seamlessly for different projects.
- Install specific versions required by a project's `package.json`.
- Avoid global installation conflicts.
How to Install nvm
The most common and recommended way to install nvm is by using an automated installation script provided by the nvm project on GitHub. This script handles downloading the latest version of nvm and setting up your environment correctly.
Prerequisites
Before you begin, ensure you have a Unix-like environment. nvm is designed for macOS, Linux, and Windows Subsystem for Linux (WSL). It does not natively support Windows Command Prompt or PowerShell directly, though workarounds exist (like using WSL).
Installation Steps
1. Open your terminal: Launch your preferred terminal application.
2. Download and run the installation script: You can use either `curl` or `wget` to fetch the script. The commands below are examples and you should always check the official nvm repository for the most current installation instructions and version numbers.
Using curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash Using wget:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashNote: Replace v0.39.7 with the latest stable version of nvm available on the official GitHub repository.
3. Verify the installation: The script will attempt to add the necessary nvm configuration lines to your shell profile file (e.g., ~/.bashrc, ~/.zshrc, ~/.profile). After the script finishes, you need to either close and reopen your terminal or explicitly source your profile file. For example, if you use Bash:
source ~/.bashrcOr for Zsh:
source ~/.zshrc4. Check nvm version: Once your terminal is reloaded, you can verify that nvm is installed and accessible by running:
nvm --versionIf nvm is installed correctly, this command will output the installed nvm version number.
Troubleshooting Common Installation Issues
- Command not found: If you run
nvm --versionand get an error likecommand not found, it usually means the nvm environment variables haven't been loaded into your current shell session. Ensure you've closed and reopened your terminal or sourced the correct profile file (~/.bashrc,~/.zshrc, etc.). Check that the lines added by the install script are present in your profile file. - Script errors: If the installation script itself encounters errors, review the output for specific messages. Common causes include network issues preventing script download or insufficient permissions. You might need to run the command with
sudoif permissions are an issue, but this is generally not recommended for nvm installation unless explicitly instructed. - Incorrect profile file: Ensure the installation script correctly identified and modified your shell's profile file. If you're unsure which shell you're using, you can often check with
echo $SHELL.
Getting Started with nvm
Once nvm is installed, you can start managing Node.js versions:
- Install a Node.js version:
nvm install 18 # Installs the latest LTS version of Node.js 18nvm install 20.11.0 # Installs a specific versionnvm lsnvm use 18 # Sets Node.js 18 as the active version for the current shell sessionnvm alias default 18 # Sets Node.js 18 as the default for new shell sessionsBy following these steps, you can effectively install and begin using nvm to manage your Node.js development environments.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
Missing an answer?
Suggest a question and we'll generate an answer for it.