Node Version Manager (NVM) is a powerful tool that allows you to easily manage multiple versions of Node.js on your system. This is especially useful for developers who work on multiple projects that require different Node.js versions. In this guide, we’ll walk you through installing and using NVM.
🔗 Downloading NVM
To get started, visit the official NVM GitHub repository. While we provide installation commands below, it's always a good idea to check their GitHub for the latest release.
📥 Installing NVM
You can install NVM using either curl
or wget
. Run one of the following commands in your terminal:
Using curl
:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Using wget
:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Note: The version number (
v0.40.1
) may change over time. Always check NVM’s GitHub for the latest version.
🔄 Reloading Shell Configuration
Once installed, reload your shell configuration so NVM is available in your current session:
source ~/.bashrc # For Bash users
For zsh
users:
source ~/.zshrc
For fish
users:
source ~/.config/fish/config.fish
🔍 Checking Available Node.js Versions
To see the list of available Node.js versions:
nvm list-remote
This will output all Node.js versions available for installation.
⬇️ Installing the Latest LTS Version of Node.js
If you want to install the latest Long-Term Support (LTS) version of Node.js, run:
nvm install --lts
Once installed, verify the installed version with:
node -v
🎯 Switching Between Node.js Versions
To list all installed Node.js versions on your system:
nvm list
To switch between different versions:
nvm use <version>
For example:
nvm use 18.16.0
To set a default Node.js version for new terminal sessions:
nvm alias default <version>
Now you can install other package managers like yarn
or pnpm
and use them to manage your Node.js projects.
PNPM
Link: https://pnpm.io/installation
npm install -g pnpm@latest-10
Yarn
Link: https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable
npm install --global yarn
🚀 Wrapping Up
You now have NVM installed and configured on your system. With NVM, you can seamlessly switch between different Node.js versions and manage your development environment efficiently.
If you encounter any issues, refer to the official NVM documentation for troubleshooting steps. Happy coding! 🎉