NVM nanny 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
insert image description here
Compressed version download: https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-setup .zip

insert image description here
Installation:
insert image description here
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 路径最好不要带中文
insert image description here
specify the nodejs installation path
insert image description here
Test
Open the command line, enter nvm -v to view the version, that is, the installation is successful
insert image description here

3. Use of NVM

Settings
Set the download source, modify setting.txt, and edit setting.txt under the installation root path.
insert image description here
Add the following two lines of mirror address

node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

insert image description here

use

nvm list available // Display all versions of node.js that can be installed
insert image description here
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版本号] :设置默认版本

Guess you like

Origin blog.csdn.net/zch981964/article/details/132099675