nvm
1. Concept
It is specially used to manage installed node versions. It can be used to switch node versions, delete specified nodes, install specified node versions, etc.
2. nvm installation and uninstallation (windows)
2.1 Prerequisite
Uninstall the node version originally installed on the computer
(1) Control Panel=> Uninstall=> Find node.exe to uninstall
( 2) Delete the node installation directory
(3) Delete the node-related environment variables
(4) Delete the node-related items under C:\user\programs Files files
2.2 Install nvm
Download from github:github download address
For example, here we take the installation of version 1.18.0 as an example
For the version that needs to be installed
Download the nvm-setup.exe
installation package, unzip and install
Open the nvm installation directory and find the setting file , add the Taobao image at the end of the file to speed up the download of node
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
The installed version will automatically configure environment variables
2.3 Uninstall nvm
Just delete the nvm installation directory
3. nvm installation (mac version)
method one
Official website
Copy the URL and follow the content in the URL. The general steps are as follows:
Pay attention to the official website and follow the official website
1. Installation
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
If you are asked to install xcode along the way, just follow the prompts and install it.
2. Configuration
Edit the following configuration file
sudo vim ~/.bash_profile
sudo vim ~/.~/.zshrc
sudo vim ~/.profile
Add the following content to each of the above three configuration files:
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
3. Update configuration file
sudo source ~/.bash_profile
sudo source ~/.~/.zshrc
sudo source ~/.profile
Method 2
Install using mac’s brew package management tool
brew install nvm
If you have not installed brew, you can execute the following command to install it. Select the appropriate domestic image download source through the serial number to speed up the download.
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
4. Commonly used commands
Install node
nvm install node版本号
例如:
nvm install 14.18.0
Uninstall node
nvm uninstall node版本号
Use the specified node version
nvm use node版本
例如:
nvm use 16.14.0
Display all nodes managed by nvm
nvm ls
Display the currently used node version
nvm current
Show nvm version
nvm version
Display all available node versions on the Internet
nvm list available
If you want to change the default node version on Mac, using
nvm use node版本
naming will only temporarily change the node version. When you start it next time, it will still be the original default version, so you need to execute the following command. Select node version
nvm alias default node版本