overview
I recently learned about the cloud project, and the front end uses technologies such as vue3 + ts. When starting the vue3 project, a higher node version (16.15.0) is required, but I don’t want to uninstall the original version. At this time, node multi-version management is required. According to the project The method provided by the official document is recorded here .
1. Install nvm
windows install nvm
-
You need to uninstall the locally installed Node.js first, and then download nvm , address:
https://github.com/coreybutler/nvm-windows/releases -
In general, find the latest version, and then download the nvm-setup.exe file . After downloading, we can double-click to install it.
-
We use PowerShell to open the command line. It should be noted here that PowerShell must be opened as an administrator , as follows:
-
Command nvm version, you can view the version number , as follows
linux install nvm
- In the Linux warehouse of nvm, there are corresponding tutorials , warehouse address: https://github.com/nvm-sh/nvm
- Installing nvm is very simple, just execute the following command
# 下载并执行安装脚本
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# 使nvm命令生效
source ~/.bashrc
- The nvm command on linux is somewhat different from that on windows, but the basic usage is the same . You can check the instructions on github for details, so I won’t introduce it here.
2. Install nodejs
After we have installed nvm, install Node.js through nvm , as follows:
- To view the list of available versions of Node.js , execute the following command:
nvm ls available
- To install Node.js with version number 16.15.0 , execute the following command:
nvm install 16.15.0
- To view the installed version number , execute the following command:
nvm list
- To switch the version number to 16.15.0 (specify your own version number) , you can execute the following command:
nvm use 16.15.0
- To view the current version number of Node.js , execute the following command:
node -v
- To uninstall Node.js whose version number is 16.15.0 (specify your own version number) , you can execute the following command:
nvm uninstall 16.15.0