There are two ways in the decision for using different version of Node. Second way is more convenient and practical by my opinion (also may be faster).
First way:
Install other Node version(for example 14) with using:
brew install |
brew unlink |
brew link |
|---|---|---|
| brew install - github | brew unlink - github | brew link - github |
brew install node@14
brew unlink node
brew link node@14
node -v
PS You may use brew link with flag --overwrite, for example:
brew link --overwrite node@14
PS2 Why unlink and then link again?
Documentation:
Remove symlinks for formula from Homebrew’s prefix. This can be
useful for temporarily disabling a formula:
brew unlink formula && commands && brew link formula
In other words:
if you have both node and node@14 installed, where node is other version(..,15 or 16), so, for set active version 14:
you must unlink node |
and then link to new installed version 14 |
|---|---|
brew unlink node |
brew link node@14 |
Second way:
Install Node Version Manager(nvm) and select Node version:
nvm - github nvm - home brew
brew install nvm
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && . "$(brew --prefix)/opt/nvm/nvm.sh" # This loads nvm
[ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && . "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
nvm install 14
nvm use 14
nvm list