Installation to use of nvm node package manager (super detailed)

1. Uninstall the current computer node.js

Be sure to uninstall the node in the current computer first

Especially environment variables and .npmrc files (this file is recommended to use the everything tool to find and delete this file in the user directory of the C drive )

Otherwise, the node.js installation may fail later

But if it is an environment variable that is automatically deployed during installation, you don't have to worry about environment variables and file residues

2. Download the nvm package manager

Git download address: https://github.com/coreybutler/nvm-windows/releases

Ali cloud disk download address (installation version): Ali cloud disk sharing   password: 16md

It is recommended to download the installation version to automatically configure environment variables to save a lot of operations

3. Installation

        1. Agree to the installation agreement

         

        2. Select the installation location of the nvm package manager

        will be useful later

        

        3. Select the node installation location 

          After installing nvm, you will reinstall node later. This installation location is where you reinstall node.

        

        4. In the last step, click Install  

       

        5. Check whether the installation is successful

        Run cmd - enter nvm directly - check if the installation is successful The following conditions represent a successful installation

4. Configuration and use

Open the nvm installation directory to find settings.txt and open it

Since I have already installed node, there will be v14 and v16 folders

Add the following two lines of code to set the Taobao mirror source 

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

Enter the following command to view the downloadable node version number

nvm list available

It is recommended to install the LTS stable version of node   

The installation/switching steps are as follows

// 查看已安装的nodejs版本
nvm list

// 安装指定nodejs版本
nvm install 14.19.3

// 使用或切换版本
nvm use 14.19.3

5. Recommended common commands

nvm articles

// 显示当前node是运行在32位还是64位环境
nvm arch                 

// 显示nvm版本号
nvm version              

node articles

// 安装指定版本nodejs
nvm install 版本号   
// 卸载指定版本nodejs
nvm uninstall 版本号
// 使用该版本的nodejs   
nvm use 版本号
// 查看已安装的nodejs版本  list可缩写为ls  即nvm ls       
nvm list               
// 显示可下载的nodejs版本号  
nvm list available 
// 开启nodejs版本管理      
nvm on               
// 关闭nodejs版本管理    
nvm off                  
// 设置下载代理,不添加url,显示当前代理,将url设置为none时则移除代理
nvm proxy [url]    
// 设置node镜像 默认url是https://nodejs.org/dist/ 也可在安装目录的settings.txt文件内手动设置
nvm node_mirror [url]    
// 设置npm 镜像 默认url是https://github.com/npm/cli/archive  设也可在安装目录的settings.txt文件内手动设置
nvm npm_mirror [url]   
// 设置存储不同版本的nodejs目录,如未设置,默认使用当前目录
nvm root [path]          

6. Intractable diseases

I heard that the old version of node will have garbled characters. I haven’t seen it before.

Guess you like

Origin blog.csdn.net/weixin_46607967/article/details/129079699