本文介绍: npm—设置淘宝镜像时报“certificate has expired“的错误

今天使用vue create my-app 创建项目时,竟然报错:

Error: Command failed: npm info vue-cli-version-marker  --json --registry=https://registry.npm.taobao.org
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/vue-cli-version-marker failed, reason: certificate has expired

在这里插入图片描述
原来是淘宝镜像过期了,我们只需要将命令替换成

 npm config set registry https://registry.npmmirror.com 

查看当前使用的npm镜像源

npm config get registry

还可以使用nrm查看和切换镜像

nrm ls

在这里插入图片描述

ok,替换成功;

但是执行完后依旧是报同样的报错,请依次执行以下两行命令

npm cache clean --force
npm config set strict-ssl false

万事大吉!继续搬砖。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注