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命令安装依赖包,忽略可选依赖项。

遇到如下错误:

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

可尝试:

清除缓存:清除 npm 的缓存,以确保获取最新的 SSL 证书信息:npm cache clean --force1、使用其他 registry 地址:尝试使用其他 registry 地址来下载包,例如使用官方的 npm registry。npm config set registry https://registry.npmjs.org/或者2、取消ssl证书验证npm config set strict-ssl false

遇到这个:

npm ERR! code EPERMnpm ERR! syscall opennpm ERR! path D:\Git\.npmrcnpm ERR! errno -4048npm 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 thenpm ERR! permissions of the file and its containing directories, or try runningnpm ERR! the command again as root/Administrator.

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