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.

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

相关推荐
阿阳微客25 分钟前
Steam 搬砖项目深度拆解:从抵触到真香的转型之路
前端·笔记·学习·游戏
德育处主任Pro1 小时前
『React』Fragment的用法及简写形式
前端·javascript·react.js
CodeBlossom1 小时前
javaweb -html -CSS
前端·javascript·html
打小就很皮...2 小时前
HBuilder 发行Android(apk包)全流程指南
前端·javascript·微信小程序
集成显卡3 小时前
PlayWright | 初识微软出品的 WEB 应用自动化测试框架
前端·chrome·测试工具·microsoft·自动化·edge浏览器
前端小趴菜054 小时前
React - 组件通信
前端·react.js·前端框架
xd000024 小时前
11. vue pinia 和react redux、jotai对比
node.js
Amy_cx4 小时前
在表单输入框按回车页面刷新的问题
前端·elementui
dancing9994 小时前
cocos3.X的oops框架oops-plugin-excel-to-json改进兼容多表单导出功能
前端·javascript·typescript·游戏程序
后海 0_o5 小时前
2025前端微服务 - 无界 的实战应用
前端·微服务·架构