Created: 2024-01-01 11:30:30
Status: #note/note

Recall:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 列出可用的版本
nvm list available

# 安装需要的版本
nvm install 20.10.0 64

# 切换到需要的版本 记住要标识架构,否则后面需要用nvm arch 64单独设置
nvm use 20.10.0 64

# 安装完成,重启控制台,检查相关版本和安装
node -v
npm -v
npm list -g

#淘宝镜像
npm config set registry https://registry.npmmirror.com
#腾讯云镜像
npm config set registry http://mirrors.cloud.tencent.com/npm/
#华为云镜像
npm config set registry https://mirrors.huaweicloud.com/repository/npm/

#验证镜像命令
npm config get registry

#使用淘宝定制的cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
#使用cnpm
cnpm install xx


#全局module的保存目录不再是exe安装时默认的c:\users\用户名\appdata\roaming\npm里面,而是直接安装在nvm的安装目录里,更方便控制安装位置
#以下内容为默认安装long-term support版本,我没有测试
nvm install --lts
nvm uninstall --lts
nvm use --lts

# 第一次用vue create 会提示选择包管理器,如果选择了vue3和yarn会默认保存在c:\user\用户名\.vuerc里
{

  "useTaobaoRegistry": true,

  "packageManager": "yarn"

}
# 修 packageManager为 npm即可

Summary:

See also
References