在使用npm install 安装依赖时报错
例如:
npm install
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/core-js failed, reason: certificate has expired
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\JarJi\AppData\Roaming\npm-cache\_logs\2024-04-01T05_31_15_285Z-debug.log
从这个报错中我们可以看出来这里已经有一句:
npm ERR! request to https://registry.npm.taobao.org/core-js failed,reason: certificate has expired
// 原因https://registry.npm.taobao.org证书已过期
意思就是我们之前设置的 https://registry.npm.taobao.org/core-js 源地址已经更新不在使用,搜导致的无法找到源地址。
解决问题
解决这个问题其实也很简单,只要将我们过期的源地址进行更换最新的源地址即可。
使用npm config set registry更改镜像源:
npm config set registry 指定的源镜像地址
NPM官方镜像:
npm config set registry https://registry.npmjs.org/
淘宝NPM镜像:
npm config set registry https://registry.npm.taobao.org
腾讯云NPM镜像:
npm config set registry https://mirrors.cloud.tencent.com/npm/
华为云NPM镜像:
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
网易NPM镜像:
npm config set registry https://mirrors.163.com/npm/
中国科学技术大学开源镜像:
npm config set registry http://mirrors.ustc.edu.cn/
清华大学开源镜像:
npm config set registry https://mirrors.tuna.tsinghua.edu.cn/
选择一个合适的云镜像设置后再次执行npm install即可完成安装