Install & update NVM
Run one of the following commands to install & update the NVM, or download the install file to update it
The curl - o - https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash wget -- qO https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bashCopy the code
NVM is installed in the ~/.nvm directory and appends the following code snippets to the 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
Copy the code
Install the node
Install the latest version of Node
nvm install node # "node" is an alias for the latest version
Install the specified version of NodeNVM install 6.14.4# or 10.10.0, 8.9.1, etc
Install the latest LTS(long-term Support) version of Node
nvm install --lts
Copy the code
Viewing node Installation
View all versions of the remote Node
nvm ls-remote
View all LTS versions of the remote Node
nvm ls-remote --lts
Check the local Node version
nvm ls
Check the current Node version in use
nvm current
# Check the node installation location
nvm which 14
Copy the code
Using the Node version
The current shell uses a Node versionNVM use <node version ># specify the global default version
nvm aliasDefault < Node version number >Copy the code
Delete the node
NVM uninstall < Node version number/alias >Copy the code
reference
NVM official documentation