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

部署Flutter网站至Firebase Hosting时遇框架检测失败错误求助

解决Flutter Web部署Firebase Hosting时的框架检测错误

问题重现

部署Flutter Web到Firebase Hosting时执行firebase deploy,出现错误:

Error: Unable to detect the web framework in use, check firebase-debug.log for more info.
降级firebase-tools版本后问题仍存在。

可行解决方案

1. 直接指定部署托管服务,跳过框架检测

执行部署命令时添加--only hosting参数,强制只部署Hosting部分,绕开框架检测逻辑:

firebase deploy --only hosting

2. 修正firebase.json配置

确保firebase.json的Hosting配置正确,重点检查以下几点:

  • public字段必须指向Flutter Web的构建输出目录build/web(Firebase Hosting用public定义静态文件根目录,而非source)
  • 添加单页应用路由重写规则,避免页面刷新出现404
    示例配置:
{
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

3. 重新初始化Hosting(跳过框架自动检测)

如果之前的初始化流程有问题,重新执行初始化:

  1. 运行firebase init hosting
  2. 当询问What do you want to use as your public directory?时,输入build/web
  3. 询问Configure as a single-page app (rewrite all urls to /index.html)?选择Yes
  4. 其他非必要配置(如GitHub Action部署)选择No
    完成后再执行firebase deploy --only hosting

4. 清理登录缓存后重试

如果是身份验证或缓存导致的异常,执行以下步骤:

firebase logout
firebase login
firebase deploy --only hosting

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 03:41:10