NVM - Node version manager
NVM (Node Version Manager by the user creationix on GitHub) is a tool that allows the user to switch between different versions of Node.js, helping reduce overhead when reproducing production bugs in development environments. When developing Node.js applications, you may need to install multiple versions of Node.js in order to handle your day-to-day tasks.
There are two different GitHub repositories for two different platforms setups : ( MacOS/Linux and Windows OS)
macOS/Linux Setup:
To install NVM on the system you may either download and run the script manually or use the following commands :
cURL command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Wget command
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
With the above command, nvm will download a script and run it on your system. The script clones the nvm repository from GitHub to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
This will complete your NVM installation on the system now you are good to go to install and use multiple Node.js versions on your system.
if necessary follow the instructions from the NVM official GitHub channel.
Windows OS:
To install NVM on the system simply download the NVM window installer, then double-click on the windows setup wizard, you need to follow simple steps on the installer.
Now you are ready to use NVM with different Node.js Versions.
Installation and Use of NVM with respect to Node.js:
- Check NVM version
C:\>nvm version
- Installation of Node
//nvm install the latest available version of Node. c:\>nvm install node //nvm install the latest LTS release c:\>nvm install --lts //Install a specific version. Ex:- nvm install v11.14.0 c:\>nvm install <version number>
- View locally installed versions List.
c:\>nvm ls
- Switch to node version
//Switch to latest installed version. c:\>nvm use node //Switch to a specific version of Node. Ex: nvm use v11.14.0 c:\>nvm use <version number>
Happy coding....... :)