Node Version Manager (NVM) simplifies the management of different Node.js versions, allowing developers to switch seamlessly between them. In this section, we will walk you through the process of installing, listing, switching between Node versions, creating aliases, and installing the latest LTS Node.js release using NVM.
–> To Install NVM, click here!
Step 4: Install Node Versions
Installing Node versions with NVM is straightforward. To install the latest Node version, use the following command:
nvm install node
If you need a specific version, you can specify the major or minor release number. First, list the available versions with:
nvm ls-remote
Then, install your desired version:
nvm install <version>
Step 5: List Installed Node Versions
To view a list of all installed Node versions and aliases, along with the currently active version, run:
nvm ls
This command provides a clear overview of your Node environment.
Step 6: Switch Between Node Versions
NVM allows you to easily switch between installed Node versions. To select a different Node version, use:
nvm use <version>
You can specify either the version number or an alias like ‘node’. To confirm the currently active Node version, run:
nvm current
Step 7: Create NVM Aliases
Aliases in NVM make managing Node versions more convenient. To change the default Node version, use:
nvm alias default 14
Installing the Latest LTS Node.js Release
Step 8: Install Latest LTS Node.js
To install the latest LTS version of Node.js, use the following command:
nvm install --lts
This command ensures that you have the latest LTS release installed.
Step 9: Switch to the Latest LTS Version
Once the latest LTS Node.js version is installed, you can switch to it by running:
nvm use --lts
This command sets the LTS version as the active Node.js version.
Additional NVM Capabilities
Apart from the basics, NVM offers advanced features. These include migrating packages from an earlier Node version, customizing colors, and specifying a default Node version in the .nvmrc
file. Refer to the NVM GitHub page for in-depth information on these capabilities.
Uninstalling Node Versions
Step 10: Uninstall Node Versions
If you need to remove a Node version that is no longer required, you can do so with the following command:
nvm uninstall <version>
Please note that you cannot uninstall a version that is currently in use. First, switch to a different version, and then proceed with the uninstallation.
Step 11: Uninstall NVM
If you decide to uninstall NVM entirely, follow these steps:
- Deactivate NVM by running:
nvm deactivate
- Unload NVM with:
nvm unload
Conclusion
Node Version Manager (NVM) is an invaluable tool for Node.js developers, offering an elegant solution for managing multiple Node versions. With NVM, you can easily install, switch, and alias Node versions, ensuring compatibility with your projects. Additionally, NVM simplifies the process of installing the latest LTS Node.js release and provides advanced capabilities for fine-tuning your development environment. Whether you’re a beginner or an experienced developer, NVM is a must-have tool to streamline your Node.js development workflow.