1. Introduction to NVM
In the process of project development, using the vue framework technology, you need to install node to download project dependencies, but often encounter node version mismatches that cause normal downloads, and reinstalling node is very troublesome. In order to solve the above problems, nvm: a node version management tool, can manage the installation and use of node, easy to use, can download the specified node version and switch between different versions, which is convenient for the use of node.
2. NVM installation
2.1 download
Installation package download address:
https://github.com/coreybutler/nvm-windows/releases
Windows system download nvm-setup.zip installation package
2.2 Installation
Double-click nvm-setup.exe to start the installation (it is best to uninstall the node already installed on the computer before installation)
Select the nvm installation root path
Specify the installation path of nodejs (it is best to create a new nodejs folder in advance and select it during installation)
2.3 Testing
Open the command line, enter nvm -v to view the version, that is, the installation is successful
3. Use of NVM
3.1 Settings
Set the download source, modify setting.txt
Edit setting.txt under the installation root path
Add the following two lines of mirror address
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
3.2 use
1.nvm list available // Display all node.js versions that can be installed
2.nvm install 16.13.1 // The named version of installing node.js is the version
3.nvm list //View installed node.js
4.nvm use 16.13.1 // switch to use the specified nodejs version
* Indicates that the currently used node version is 16.13.1
Four, NVM common commands
nvm off // 禁用node.js版本管理(不卸载任何东西)
nvm on // 启用node.js版本管理
nvm install <version> // 安装node.js的命名 version是版本号 例如:nvm install 8.12.0
nvm uninstall <version> // 卸载node.js是的命令,卸载指定版本的nodejs,当安装失败时卸载使用
nvm ls // 显示所有安装的node.js版本
nvm list available // 显示可以安装的所有node.js的版本
nvm use <version> // 切换到使用指定的nodejs版本
nvm v // 显示nvm版本
nvm install stable // 安装最新稳定版
Five, NVM common abnormalities
1. nvm use fails and node cannot be used
Reason: The installation path of nodejs was modified when installing nvm, but the installation package did not create a new nodejs in the specified path
Solution: Manually create a new nodejs folder in the specified path, reinstall and specify the path