Node Version Manager (NVM) is a tool that allows you to manage multiple versions of Node.js on your computer.
Node Version Manager makes it easy to switch between different versions of Node.js so that you can work on various projects with the appropriate Node.js version without conflicts.
NVM allows you to set both a global and local Node.js version. The global version is the default for your system, while the local version can be set on a per-project basis, ensuring that each project can use the appropriate Node.js version.
NVM also provides commands to update itself and uninstall Node.js versions when they are no longer needed.
You can use the following steps to install Node Version Manager (NVM) on your PC
- Install NVM via curl or wget
Open your terminal. For the installation, you will use the command line.
You can install NVM using the curl command or wget commands depending on the command available on your device.
For curl, use the command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
The NVM installation script will be downloaded and executed with this command. Replace 0.39.0 with the recent version.
You can also use wget.
For Wget, use the following command :
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
- Close and Reopen your terminal
To check that NVM is available in your current terminal session, either close and reopen your terminal or perform the following command to refresh your terminal :
If you’re using ~/.zshrc (Zsh), replace ~/.bashrc with ~/.zshrc.
- Verify NVM installation
To verify NVM is installed correctly, run the following command :
This should display the version of NVM that you installed.
- Install specific node versions
The specific version of Node.js can be installed by running the following command:
nvm install <version>
Replace <version> with the version of Node.js required for the project.
(example: nvm install v14.19.3)
- Set Default Node.js Version
If you want to set a default Node.js version to use, you can run:
nvm alias default <version>
Replace <version>with the Node.js version you want as the default.
Example: nvm alias default 16.15
- Switch Between Node.js Versions
You can easily switch between installed Node.js versions using the nvm use command.
For example, nvm use 16.16.0
- List all installed Node js versions
To list the Node.js versions currently installed on your system using Node Version Manager (NVM) use the command nvm ls. When you run this command, NVM will display a list of installed Node.js versions along with an indication of which version is currently in use (marked with an arrow ->).
- List all available versions of Node js
Use the command nvm ls-remote to list the remote or available versions of Node.js that you can install using Node Version Manager (NVM). It displays a list of Node.js versions that can be installed using NVM.
- Uninstall a specific version of Node.js
The nvm uninstall command in Node Version Manager (NVM) is used to uninstall a specific version of Node.js from your system. This can be useful if you want to remove a Node.js version that you no longer need or if you need to free up disk space.
Example: nvm uninstall 14.15.4
In conclusion, Node Version Manager (NVM) is a valuable tool for developers who work with Node.js. It simplifies the management of multiple Node.js versions on a single machine, allowing developers to switch between versions easily, isolate projects with different version requirements, and maintain global npm packages specific to each Node.js version. NVM is a powerful utility that streamlines the development process and ensures compatibility and consistency across different projects. It’s a must-have for Node.js developers who need to work with different Node.js versions in their daily workflow.
Sreyas is a prominent software and mobile app development firm, boasting extensive expertise in UI/UX design. Our global presence allows us to offer a comprehensive range of services, including data migration, database management, web hosting, infrastructure management, and more to clients worldwide.