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

创建React项目时遭遇SELF_SIGNED_CERT_IN_CHAIN错误求助

React应用创建失败:SELF_SIGNED_CERT_IN_CHAIN错误

错误详情

PS C:\Users\Tashs November\Desktop\Event Management> npm create vite@lite
npm error code SELF_SIGNED_CERT_IN_CHAIN
npm error request to https://registry.npmjs.org/create-vite failed, reason: 证书链中存在自签名证书
npm error 本次运行的完整日志可查看:C:\Users\Tashs November\AppData\Local\npm-cache_logs\2024-07-31T08_45_49_900Z-debug-0.log

PS C:\Users\Tashs November\Desktop\Event Management> npm create vite@latest
npm error code SELF_SIGNED_CERT_IN_CHAIN
npm error errno SELF_SIGNED_CERT_IN_CHAIN

已尝试的命令(均失败)

  • npm create vite@latest
  • npm create vite@lite
  • npx create-react-app events management

解决方法

临时跳过证书校验(仅临时使用,不推荐生产环境)

执行命令关闭npm的严格证书校验:

npm config set strict-ssl false

完成应用创建后,建议重新开启校验:

npm config set strict-ssl true

配置代理信任证书(推荐网络环境受限场景)

若处于公司代理或内网环境,将代理根证书添加到npm信任列表:

  1. 获取代理提供的根证书文件(格式通常为.crt或.pem)
  2. 执行命令配置证书路径:
npm config set cafile "C:\你证书的完整路径\证书文件名.crt"

切换npm镜像源

如果上述方法无效,可尝试切换到国内镜像源:

npm config set registry https://registry.npmmirror.com/

设置完成后重新执行应用创建命令。

内容的提问来源于stack exchange,提问作者Ruvimbo November

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 09:11:06