nvm installation configuration
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
Download:
Release version download: https://github.com/coreybutler/nvm-windows/releases
Compressed version download: https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-setup .zip
Installation:
If you installed node.js before, you need to uninstall it first,
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users{User}\AppData\Roaming\npm (or % appdata%\npm)
C:\Users{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
Check your %PATH% environment variable to ensure that there is no reference to Nodejs or npm,
then install it, select the nvm installation root path, and 路径最好不要带中文
specify the nodejs installation path
Test
Open the command line, enter nvm -v to view the version, that is, the installation is successful
3. Use of NVM
Settings
Set the download source, modify setting.txt, and 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/
use
nvm list available // Display all versions of node.js that can be installed
nvm install 18.16.0 // Install node 18.16.0
nvm install 14.19.1 // Install node 18.16.0
nvm list // View installed nodes .js
nvm use 14.19.1 // switch node to the specified nodejs version
Four, NVM common commands
nvm ls-remote :列出所有远程服务器的版本(官方node version list)
nvm list (可简化为nvm ls):列出所有已安装的 node 版本
nvm list available :显示所有可下载的版本
nvm install stable :安装最新版 node
nvm install [node版本号] :安装指定版本 node
nvm uninstall [node版本号] :删除已安装的指定版本
nvm use [node版本号] :切换到指定版本 node
nvm current :当前 node 版本
nvm alias [别名] [node版本号] :给不同的版本号添加别名
nvm unalias [别名] :删除已定义的别名
nvm alias default [node版本号] :设置默认版本