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

Firebase部署报错:指定public目录不存在,请求排查问题

Firebase Hosting部署报错:指定的public目录不存在的排查方案

核心问题:路径格式错误

你在firebase.json里配置的"public": "/view/build"是绝对路径,但Firebase Hosting会以firebase.json所在的目录(即Firebase Practice根目录)为基准解析路径,必须使用相对路径。开头的斜杠会让Firebase去系统根目录寻找view/build,自然找不到实际存在的子目录。

修正后的配置

将hosting字段里的public路径改为相对路径即可:

{
  "functions": {
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "view/build", // 去掉开头的斜杠,改为相对路径
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/api/*",
        "function": "api"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

额外验证步骤

  • 确认view/build目录确实存在,且包含index.html、static/js等必要文件
  • 执行firebase deploy时,确保当前工作目录是Firebase Practice根目录(即firebase.json所在的目录)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 03:55:18