Install NVM for Node

Node Version Manager (NVM), as the name implies, It is a tool for managing Node versions on your device.

Different projects on your device may be using different versions of Node. Using only one version (the one installed by npm ) for these different projects may not give you accurate execution results.

So NVM needed to easily change version of node as per your projects or applications.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

After installation

open .bash_profile or .zshrc file and add below lines

vi ~/.zshrc

export NVM_DIR=”/Users/apple/.nvm”
[ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm
[ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion

source ~/.zshrc

OR

vi ~/.bash_profile

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

source ~/.bash_profile

Now Check NVM it is installed now

nvm –version

for details go to site : https://github.com/nvm-sh/nvm

You can list down all node versions via below command

nvm ls

Also use node by command

nvm use 14 or any other version

Related Posts

Leave a Reply

Your email address will not be published.