You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装@mui/lab时遇UNABLE_TO_VERIFY_LEAF_SIGNATURE及403错误求助

安装@mui/lab时遇到UNABLE_TO_VERIFY_LEAF_SIGNATURE和E403错误的解决方法

问题场景

安装@mui/lab时触发SSL验证错误:

npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://pkg.csb.dev/mui/mui-x/commit/1f23b33d/@mui/x-tree-view failed, reason: unable to verify the first certificate

将strict-ssl设为false后,又出现403权限错误:

26.16 npm ERR! code E403
26.16 npm ERR! 403 403 Forbidden - GET https://pkg.csb.dev/mui/mui-x/commit/1f23b33d/@mui/x-tree-view
26.16 npm ERR! 403 In most cases, you or one of your dependencies are requesting
26.16 npm ERR! 403 a package version that is forbidden by your security policy.
26.16 npm ERR! 403 
26.16 npm ERR! 403 It was specified as a dependency of '@mui/lab'
26.16 npm ERR! 403 
26.19 
26.19 npm ERR! A complete log of this run can be found in:
26.19 npm ERR!     /root/.npm/_logs/2023-09-07T10_50_32_206Z-debug.log

使用的Node版本:14.18.1

解决方法

1. 强制替换依赖源

问题根源是@mui/lab依赖的@mui/x-tree-view指向了csb.dev的私有构建版本,该源存在访问限制。可通过package.json的overrides字段强制使用npm官方源的包:
在项目package.json中添加:

"overrides": {
  "@mui/x-tree-view": "^6.0.0" // 或指定稳定版本,如latest
}

之后重新执行npm install。

2. 更新npm版本

Node 14.18.1配套的npm版本较旧,可能存在兼容性问题。执行命令更新npm:

npm install -g npm@latest

更新完成后重试安装@mui/lab。

3. 配置CA证书替代关闭strict-ssl

关闭strict-ssl存在安全风险,建议配置系统信任的CA证书:

  • 找到本地CA证书文件(如ca.pem)
  • 执行命令配置:
npm config set cafile /path/to/your/ca.pem
  • 恢复strict-ssl为true:
npm config set strict-ssl true

再重新安装依赖。

4. 清除npm缓存

缓存可能残留旧的源地址,执行命令清理:

npm cache clean --force

之后重新执行npm install @mui/lab。

内容的提问来源于stack exchange,提问作者Harsh Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 14:47:03