在装的过程中,使用npm有时候因为网络问题容易丢包,因此可配置一些镜像源进行优化,vue3好像也不能直接使用npm,只能使用yarn,整理了一些镜像源,推荐给大家,有错误希望能指出来,感恩。

步骤

1.直接修改镜像源

1
2
3
  $ npm config set registry https://registry.npm.taobao.org

  $ npm config get registry

2.安装cnpm (不推荐使用)

1
$ npm install -g cnpm --registry=https://registry.npm.taobao.org

3.nrm (可选 如果已经做了第1步 就不需要设置了)

1
2
3
4
5
6
7
$ npm i nrm -g

$ nrm -V 验证版本

$ nrm ls | list 查看可切换镜像源

$ nrm use cnpm | npm | taobao taobao 是最快的 建议使用

4.yarn

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$  npm i yarn -g

$ yarn -v

$ yarn config set registry https://registry.npm.taobao.org

$ yarn config get registry

$ npm 常用命令

$ npm install 包名 -g | --save-dev(-D) --save(-S)

$ npm uninstall 包名 -g | --save-dev(-D) --save(-S)

$ yarn 常用命令

$ yarn add 包名 -g | --save-dev(-D) --save(-S)

$ yarn remove 包名 -g | --save-dev(-D) --save(-S)