Node Version Manager (NVM)
Here's a step-by-step guide on how to use NVM (Node Version Manager) to install and manage specific versions of Node.js on your system:
Install NVM
If you haven't already installed NVM, you can do so by running the following command in your terminal:
Or, if you prefer using Wget:
This command will install NVM on your system. You may need to restart your terminal or run source ~/.bashrc
(or ~/.zshrc
if you use Zsh) to start using NVM.
Check NVM Version
You can verify that NVM has been installed correctly by typing:
List available Node.js versions
You can list the available Node.js versions by running:
This should display the version of NVM that you installed.
Install a Specific Version of Node.js
To install a specific version of Node.js, use the following command:
Replace X.X.X
with the version number you want to install. For example, to install Node.js version 18.18.2
:
Use the Installed Node.js Version
Once the installation is complete, you can use the installed version by typing:
For example:
You can check the current Node.js version in use with:
Set a Default Node.js Version (Optional)
If you want to set a default Node.js version to be used in new shell sessions, you can type:
For example, to set version 18.18.2
as the default:
Now you have successfully installed and managed a specific version of Node.js using NVM.
Remember that you can always switch to different versions using the nvm use
command.