作用
npm源网址(npmjs.com)是一个国外网址,下载软件包速度较慢,为了提升下载速度,可以通过更改npm的镜像地址解决该问题。
步骤
1、cmd命令中输入“npm config get registry”,该命令可以查看源地址(不需要查看可忽略)
2、cmd命令中输入“npm config set registry https://registry.npm.taobao.org ”(设置新下载地址,这里使用的是淘宝镜像地址)
3、设置好后,在cmd命令中输入“npm config get registry”,确认是否更改成功。
4、恢复默认源地址:cmd命令中输入“npm config set registry https://registry.npmjs.org/”
npm的镜像地址有以下几个:
-
官方镜像:https://registry.npmjs.org/
-
淘宝镜像:https://registry.npm.taobao.org/
-
cnpm镜像:https://r.cnpmjs.org/
-
阿里云镜像:https://npm.aliyun.com/
-
中国科技大学镜像:https://mirrors.ustc.edu.cn/npm/
-
华为云镜像:https://mirrors.huaweicloud.com/repository/npm/
-
七牛云镜像:https://npm.qiniu.com/
以上镜像地址都可以用于替换npm的默认镜像地址,以加速依赖包的下载和安装。