npm taobao镜像提示 reason: certificate has expired

发布于:2024-04-21 ⋅ 阅读:(228) ⋅ 点赞:(0)

前言

在使用npm install安装的时候 发现有个报错提示 证书过期了
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/eslint failed, reason: certificate has expired

详细日志如下

> npm install 
(#########⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ idealTree:vue_campus_admin: timing idealTree:#root Compl
(#########⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ idealTree:vue_campus_admin: timing idealTree:#root Compl
(#########⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ idealTree:vue_campus_admin: timing idealTree:#root Compl
(#########⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ idealTree:vue_campus_admin: timing idealTree:#root Compl
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-loader@2.2.1
npm WARN Found: eslint@7.15.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"7.15.0" from the root project
npm WARN   4 more (@vue/cli-plugin-eslint, babel-eslint, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@">= 1.6.0" from @vue/cli-plugin-eslint@4.4.6
npm WARN node_modules/@vue/cli-plugin-eslint
npm WARN   dev @vue/cli-plugin-eslint@"4.4.6" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-loader@2.2.1
npm WARN Found: eslint@7.15.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"7.15.0" from the root project
npm WARN   4 more (@vue/cli-plugin-eslint, babel-eslint, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@">= 4.12.1" from babel-eslint@10.1.0
npm WARN node_modules/babel-eslint
npm WARN   dev babel-eslint@"10.1.0" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-loader@2.2.1
npm WARN Found: eslint@7.15.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"7.15.0" from the root project
npm WARN   4 more (@vue/cli-plugin-eslint, babel-eslint, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^6.2.0 || ^7.0.0" from eslint-plugin-vue@7.2.0
npm WARN node_modules/eslint-plugin-vue
npm WARN   dev eslint-plugin-vue@"7.2.0" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-loader@2.2.1
npm WARN Found: eslint@undefined
npm WARN node_modules/eslint
npm WARN   dev eslint@"7.15.0" from the root project
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@">=1.6.0 <7.0.0" from eslint-loader@2.2.1
npm WARN node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader
npm WARN   eslint-loader@"^2.2.1" from @vue/cli-plugin-eslint@4.4.6
npm WARN   node_modules/@vue/cli-plugin-eslint
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/eslint failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/local/develop/node/node_cache/_logs/2024-04-20T06_07_53_887Z-debug-0.log

解决办法

  • 清除缓存

    npm cache clean --force
    
  • 更换其他的镜像源

    # 更换阿里源
    npm config set registry https://npm.aliyun.com/
    

    其他的国内镜像源还有很多 例如:

    腾讯镜像源: http://mirrors.cloud.tencent.com/npm/
    华为镜像源: https://mirrors.huaweicloud.com/repository/npm/
    中科大镜像: https://registry.npmjs.org/
    另一个淘宝镜像:https://registry.npmmirror.com

  • 禁用 npm 的 SSL 证书严格模式 (不推荐)
    通常情况下,当 npm 与远程 registry 通信时,它会验证 registry 的 SSL 证书是否有效、是否已过期以及是否与预期的证书颁发机构匹配。当 strict-ssl 设置为 true(默认值)时,如果证书验证失败,npm 将拒绝与该 registry 通信。
    但是,在某些情况下,使用的 registry 具有自签名证书或证书已过期,则需要禁用 SSL 证书的严格验证。可以临时禁用严格模式来解决

    # 禁用 npm 的 SSL 证书严格模式
    npm config set strict-ssl false
    
  • 当使用国内镜像源的时候记得关闭梯子 (这点很重要 或者 关闭控制台命令代理 )


网站公告

今日签到

点亮在社区的每一天
去签到