This short tutorial will explain how to install node version manager (nvm) on Windows or Linux and Mac OS systems. Node Version Manager is very useful when working with node.js based projects
- 1 What is Node Version Manager?
- 2 Why developers like nvm
- 3 Installing nvm on Windows
- 4 How to install nvm on Linux or Mac OS
- 5 How to use nvm to install and switch between Node versions
- 6 Conclusion
What is Node Version Manager?
nvm stands for Node Version Manager. It’s a tool used to manage multiple Node.js versions.
nvm allows you to easily install, switch between, and manage many different versions of Node.js on a single system. This is especially useful for developers who need to test their applications across multiple Node.js versions or work on different projects that each require a specific Node.js version.
Why developers like nvm
nvm is favored in development environments where maintaining consistent Node.js versions across different projects or team members is important. It simplifies the process of managing Node.js versions and reduces potential conflicts between project dependencies and the Node.js runtime.
- Multiple Node.js Versions: Install and maintain multiple versions of Node.js and npm (Node.js package manager) without needing to manually download and configure them.
- Easy Switching: Switch between installed Node.js versions with a simple command. This helps in testing applications across different Node.js environments.
- Project-Specific Versions: You can specify a Node.js version for a specific project.
nvmwill automatically use the right version when you’re working on that project.
- No Need for Sudo:
nvminstalls Node.js in your user space, eliminating the need for
sudocommands (on Unix-based systems) and avoiding permission issues often encountered with global installations.
nvmworks on various Unix-like operating systems, including macOS and Linux. For Windows, a separate version called
nvm-windowsis available with similar functionality.
- Version Management: Easily install and uninstall different Node.js versions as needed.
- Automatic Version Switching: By placing a
.nvmrcfile in your project’s root directory with the desired Node.js version,
nvmcan automatically switch to this version when you navigate to the directory.
Installing nvm on Windows
To install NVM (Node Version Manager) on Windows, you’ll need to use a version of NVM that’s specifically designed for Windows, known as “nvm-windows”. Here’s a step-by-step guide to install it:
Download nvm for windows
There are several options for downloading
nvm for windows. I recommend downloading the
.exe file.To download
nvm for Windows:
- Go to the nvm-windows releases page on GitHub.
- Download the latest version. It’s typically provided as a
.zipfile or an installer (
.exefile). The installer version (
nvm-setup.zip) is generally easier to use.
If you downloaded the installer (
.exe file), simply run it and follow the on-screen instructions.
During the installation, the installer may prompt you to specify the paths for Node.js and npm. It will create these directories for you. We recommend using the default paths unless you need to change them for a specific reason. Proceed to complete the installation process.
Verify the Installation on Windows
Open a new command prompt or PowerShell window then run the following command to check if
nvm has been installed successfully:
- Administrator Rights: You may need administrator rights to install
nvmon Windows, especially if you are installing it in a system directory.
- Environment Variables:
nvmshould automatically set up the necessary environment variables. If you encounter any issues, you may need to manually check these settings.
- Existing Node.js Installation: If you have an existing Node.js installation, you may want to uninstall it before installing Node.js through
nvmto avoid any conflicts.
- System Restart: After installation, you might need to restart your system or at least restart your command line tool to ensure the environment variables are properly set.
By following these steps, you should be able to successfully install
nvm on your Windows system, allowing you to manage multiple Node.js versions easily.
How to install nvm on Linux or Mac OS
nvm on Ubuntu Linux or Mac OS, you can follow these steps:
Open your Terminal and download nvm
You can do this by searching for “Terminal” in your system’s application launcher or by pressing
Ctrl + Alt + T on Linux. For Mac OS find Terminal in the Applications > Utilities folder, or you can use Spotlight (
Cmd + Space) to search for it.
Use the curl or wget command to download and run the installation script. It’s important to check the latest version of NVM from the official GitHub repository for the most recent install command.
You can use the following commands: Using
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Update your System’s Environment
The script updates your bash profile to load
nvm. You need to either close and reopen your terminal or source your profile file to reflect these changes. You can source your profile with the following command:
If you’re using a different shell like Zsh, the file might be
~/.zshrc or another profile file.
Verify the Installation
After installation, verify that
nvm has been installed successfully by checking its version:
How to use nvm to install and switch between Node versions
In this section, we look at what you can do with
nvm. To use
nvm open up a command prompt, terminal, or PowerShell shell.
Now, you can install Node.js using
nvm. For instance, to install the latest version of Node.js, you can use:
nvm install node
You can also install several specific versions of Node.js depending on your needs. To install a specific version specify the version number like this:
nvm install 20.10.0
Switch Between Node Versions
There are times when you need to switch to a newer or older version of Node.js. For example, when you have an old project that is incompatible with the latest version of Node.js and you want to work on it. You can switch between installed Node.js versions with the command:
nvm use followed by the version number. For example:
nvm use 20.10.0
List Installed Node Versions
To see all the Node.js versions installed on your system through NVM, use:
To stay up to date on programming and software development-related articles follow me on X:Follow @tmdev82