Introduce NVM

NVM is the Node.js version manager through which you can install and switch between different versions of NodeJS.

Installation steps

NVM installation

Open the terminal and run the following command

The curl - o - https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bashCopy the code

Installation may fail. If you fail, try again. Then open the ~/.zshrc file, type open ~/.zshrc to open the file, and copy the code of the official website into it.

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 node using NVM

NVM install 14.17.0 Specifies the current stable node version. You can also install other versionsCopy the code

After the installation is complete, type NVM ls to view the installed Node version

You can switch node versions using NVM use

Ok, installation complete!