【问题标题】:Firebase hosting deployment error Error: Error: 404, Requested entity was not foundFirebase 托管部署错误错误:错误:404,未找到请求的实体
【发布时间】:2020-07-16 07:48:42
【问题描述】:

我在 firebase 上托管了一个静态网站,我正在使用 node.js。 当我尝试部署我的网站时,我遇到了这个错误。

 C:\Users\Ankur-PC\Desktop>firebase deploy

=== Deploying to 'wo*****win'...

i  deploying hosting

**Error: HTTP Error: 404, Requested entity was not found.**

我也在尝试使用这些 cmd 来解决此错误

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools

【问题讨论】:

    标签: node.js web-deployment firebase-hosting


    【解决方案1】:

    我必须将site 属性添加到firebase.json 才能解决此问题。

    {
      "hosting": {
        "site": "my-app-id",
        "public": "app",
        ...
        ...
    }
    

    【讨论】:

    • 是的,确实有效,非常感谢!
    【解决方案2】:

    将您的 Firebase npm 包更新到最新版本。它对我有用

    npm install -g firebase-tools

    【讨论】:

      【解决方案3】:

      除非您的网站源位于 C:\Users\Ankur-PC\Desktop ,否则您在错误目录中执行命令

      尝试 cd [源目录] 然后部署

      【讨论】:

        【解决方案4】:

        如果您有指向 Cloud Run 或 Cloud Function 的重定向,请确保它正在运行。

        【讨论】:

          【解决方案5】:

          我在 CLI 中启动项目时发生了这种情况,然后在同一个项目中设置了第二个主机。

          解决方案是编辑 firebase.json 并添加您希望部署的新主机:

          {
            "hosting": [
              {
                "target": "web-page", // <-- This is a nickname of a resource (a hosting in firebase)
                "public": "public",
                ....
              },
              {
                "target": "web-app",
                "public": "public",
                ....
              },
          
            ]
          }
          

          现在你必须选择目标:

          firebase target:apply hosting [name] [resource]
          

          例如,假设名称是 .json 中的“web-page”,而您的目标主机名称是“hosting-web”,最后一个实际上就是您在 Firebase 控制台中使用的名称:

          firebase target:apply hosting web-page hosting-web
          

          更多参考: https://firebase.google.com/docs/cli/targets

          【讨论】:

            【解决方案6】:

            您必须确保在 Firebase 控制台中添加了 Web 应用。

            然后,转到 Build -> Hosting 并进行设置。系统将提示您为站点添加名称。复制您在此处输入框中的内容...

            ...并在此处将其添加到您的 firebase.json 文件中:

            "hosting": {
            "site": "stack-overflow-example", // here
            "public": "build/web",
            "rewrites": [
              {
                "source": "**",
                "destination": "/index.html"
              }
            ]
            }
            

            【讨论】:

              【解决方案7】:

              遇到同样的问题,终于解决了。

              1.火力基地登录 2. firebase 使用 --add (选择正确的项目ID) 3. firebase init(选择托管,而不是正确的项目 ID) 4. 如果需要(npm run build) 5. 火力基地部署

              解决方案是 2 选择正确的项目 ID 因为某些 firebase 命令如何自动引用错误的项目 ID

              祝你好运

              【讨论】:

                猜你喜欢
                • 2019-04-02
                • 2021-01-15
                • 2023-01-05
                • 1970-01-01
                • 2020-04-20
                • 2021-09-22
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多