npm i 遇到了 npm ERR! code CERT_HAS_EXPIRED

npm i 遇到了 npm ERR! code CERT_HAS_EXPIRED

  1. 更新你的系统时间【命令 date】。确保你的计算机上的时间和时区设置正确,并且与当前时间相符。
  1. 清除你的 npm 缓存。使用 npm cache clean --force 命令清除你的 npm 缓存,关闭ssl验证,并重新运行 npm i 命令。
  2. 添加 --no-optional 选项强制安装必要依赖。使用 npm i --no-optional 命令安装依赖包,忽略可选依赖项。

遇到如下错误:

javascript 复制代码
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/xregexp/download/xregexp-2.0.0.tgz?cache=0&sync_timestamp=1581429204252&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxregexp%2Fdownload%2Fxregexp-2.0.0.tgz failed, reason: certificate has expired

这个问题是由于 npm 试图访问 https://registry.npm.taobao.org/xregexp/download/xregexp-2.0.0.tgz 时发现 SSL 证书已经过期所致。

可尝试:

javascript 复制代码
清除缓存:清除 npm 的缓存,以确保获取最新的 SSL 证书信息:
    npm cache clean --force

1、使用其他 registry 地址:尝试使用其他 registry 地址来下载包,例如使用官方的 npm registry。
    npm config set registry https://registry.npmjs.org/

或者

2、取消ssl证书验证
npm config set strict-ssl false

遇到这个:

bash 复制代码
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Git\.npmrc
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\Git\.npmrc'
npm ERR!  [Error: EPERM: operation not permitted, open 'D:\Git\.npmrc'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'D:\\Git\\.npmrc'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

需要管理员权限,以管理员身份打开即可

相关推荐
慧一居士7 小时前
Vite项目中使用Less步骤,详细使用示例
前端·css
花间相见7 小时前
【LangChain组件03】—— LangChain Agents 执行与状态:工作流程与状态管理实战
java·前端·langchain
kyriewen7 小时前
面试官让我用 AI 重构一个 8 年陈的 React 组件——他说他不看代码,只看我会不会拆
前端·javascript·面试
计算机魔术师7 小时前
700吉瓦「幽灵用电」:美国AI数据中心的抢电闹剧正在失控
前端
IT_陈寒8 小时前
JavaScript数组排序踩的坑,差点让我加班到凌晨
前端·人工智能·后端
风骏时光牛马8 小时前
提示词工程:大模型交互的核心构建艺术
前端
今日无bug8 小时前
大模型的回答是怎么一个字一个字蹦出来的?前端流式输出解析
前端·llm·agent
计算机魔术师8 小时前
Anthropic 复盘 Claude 模型越权访问真实系统事件并改进对齐与安全措施
前端
ELI_He9998 小时前
如何还原已经推送的提交
git
掘金者阿豪8 小时前
Seedance 2.0/2.5 虚拟素材能跨 Key 共用吗?一次讲清 Asset ID、账号隔离与 SaaS 素材架构
前端·后端