npm淘宝镜像过期解决办法

因为npm 官方镜像(registry.npmjs.org)在国内访问很慢,我们基本上都会选择切换到国内的一些 npm 镜像(淘宝镜像、腾讯云镜像等)。由于淘宝原来的镜像(registry.npm.taobao.org)HTTPS 证书正式到期,因此需要切换到淘宝最新的镜像,否则会出现证书到期异常。
在这里插入图片描述

解决办法

1.检测现在的镜像地址

npm config get registry

2.如果不是淘宝最新的镜像地址,请更换

//清空缓存
npm cache clean --force
//切换新源
npm config set registry https://registry.npmmirror.com

3.最好使用淘宝命令工具cnpm

//安装cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
//检测是否安装成功
cnpm -v
//安装你的依赖,这是我的
cnpm install vue-bus

之后安装就可以成功了
在这里插入图片描述

国内镜像还有如下,根据自己的需要使用:
腾讯:http://mirrors.cloud.tencent.com/npm/
华为:https://mirrors.huaweicloud.com/repository/npm/
中科大镜像:https://registry.npmjs.org/

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐