npm install 报错:log显示 出现 error request to https://registry.npm.taobao.org/xlsx failed, reason: certificate has expired
场景:
项目npm install时出现 npm WARN tar ENOENT: no such file or directory 查看日志发现主要的问题是: error request to https://registry.npm.taobao.org/xlsx failed, reason: certificate has expired
问题描述
安装失败:
本质上是淘宝镜像源过期了,需要把https://registry.npm.taobao.org/xlsx 替换成https://registry.npmmirror.com
24766 error code CERT_HAS_EXPIRED
24767 error errno CERT_HAS_EXPIRED
24768 error request to https://registry.npm.taobao.org/xlsx failed, reason: certificate has expired
24769 verbose exit [ 1, true ]
解决方案:
替换镜像:
- 查看当前镜像列表:npm config list
我这边的就是老的镜像源,现在需要换成新的
PS D:\study_work_project\php\CRMEB-master\template\admin> npm config list
; cli configs
metrics-registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.14.15 node/v14.18.1 win32 x64"
; userconfig C:\Users\zhangxiaoxiao\.npmrc
cache = "D:\\soft\\node-v16.16.0-win-x64\\node-v16.16.0-win-x64\\node_cache"
prefix = "D:\\soft\\node-v16.16.0-win-x64\\node-v16.16.0-win-x64\\node_global"
registry = "https://registry.npm.taobao.org/"
sass_binary_site = "https://npm.taobao.org/mirrors/node-sass"
; node bin location = D:\soft\nodejs\node.exe
; cwd = D:\study_work_project\php\CRMEB-master\template\admin
; HOME = C:\Users\zhangxiaoxiao
; "npm config ls -l" to show all defaults.
- 清理一下缓存 npm cache clean --force
PS D:\study_work_project\php\CRMEB-master\template\admin> npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
3.替换 npm config set registry https://registry.npmmirror.com
替换完成之后查看一下列表,看看是否替换完成
PS D:\study_work_project\php\CRMEB-master\template\admin> npm config set registry https://registry.npmmirror.com
PS D:\study_work_project\php\CRMEB-master\template\admin> npm config list
; cli configs
metrics-registry = "https://registry.npmmirror.com/"
scope = ""
user-agent = "npm/6.14.15 node/v14.18.1 win32 x64"
; userconfig C:\Users\zhangxiaoxiao\.npmrc
cache = "D:\\soft\\node-v16.16.0-win-x64\\node-v16.16.0-win-x64\\node_cache"
prefix = "D:\\soft\\node-v16.16.0-win-x64\\node-v16.16.0-win-x64\\node_global"
registry = "https://registry.npmmirror.com/"
sass_binary_site = "https://npm.taobao.org/mirrors/node-sass"
; node bin location = D:\soft\nodejs\node.exe
; cwd = D:\study_work_project\php\CRMEB-master\template\admin
; HOME = C:\Users\zhangxiaoxiao
; "npm config ls -l" to show all defaults.
4.执行npm install