CERT_HAS_EXPIRED 过期,切换镜象无效

177 阅读1分钟

问题背景

warning ......\package.json: No license field
TypeError: fetch failed
    at node:internal/deps/undici/undici:12502:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getVersionInfo (D:\workspace\sparrow\sparrowzoo\juejin-ui\www_shadcn\node_modules\next\dist\server\dev\hot-reloader-webpack.js:215:21)
    at async Span.traceAsyncFn (D:\workspace\sparrow\sparrowzoo\juejin-ui\www_shadcn\node_modules\next\dist\trace\trace.js:154:20)
    at async HotReloaderWebpack.start (D:\workspace\sparrow\sparrowzoo\juejin-ui\www_shadcn\node_modules\next\dist\server\dev\hot-reloader-webpack.js:607:28)
    at async startWatcher (D:\workspace\sparrow\sparrowzoo\juejin-ui\www_shadcn\node_modules\next\dist\server\lib\router  [cause]: Error: certificate has expired
      at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
      at TLSSocket.emit (node:events:519:28)
      at TLSSocket._finishInit (node:_tls_wrap:1085:8)
      at ssl.onhandshakedone (node:_tls_wrap:871:12) {
    code: 'CERT_HAS_EXPIRED'
  }
}

三个NODE 管理工具

NRM Registry

npm config set registry https://registry.npmjs.org/

NVM Version

github.com/coreybutler…

NPM Package

在mac 没有问题 windows 下不正常

  • 通过以上三个工具对镜象进行切换无效
  • 设置strict-ssl false 无效
npm config set strict-ssl false
  • 删除yarn.lock 重新编译依然无效

最终确认问题

Package.json中的next js 版本问题

next:14.2.5 //正常

版本冲突如何排查?