Manage multiple NodeJS versions using NVM
nodejssetupWhat is NVM #
NVM
is a version manager for NodeJS. It is a useful tool for managing multiple versions of NodeJS on a single development machine. It works on any POSIX_compliant shell like sh, dash, ksh, zsh, bash.
Installation #
Follow the instructions on the GitHub repo in order to install NVM
Verify the installation
command -v nvm
This should output nvm
if the installation was successful.
Usage #
Installing the latest version of NodeJS #
Install the latest version of NodeJS and NPM
nvm install node
Once installed you can check the version using the command node -v
Installing a specific version of NodeJS #
Specific version of NodeJS can be installed
nvm install 14.16.0
Again, you can check the version using the command node -v
Checking available versions #
You can check the versions available to install
nvm ls-remote
And check the installed versions using
nvm ls
Switching between versions #
In a new shell, you can switch to a different version of node
nvm use 14.16.0
Note that the version switch applies to the current shell, and does not change the default Node version that is initialized in a new shell.
NVM sets the first version that was installed as the default. In order to set a different version of Node as default, set the alias
nvm alias default 10.24.0