首页 文章

firebase部署后出现“意外错误”

提问于
浏览
3

当我通过firebase托管我的网页然后写入命令 firebase deploy 后,我收到以下错误:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\amarg\Desktop\amar>firebase init

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  C:\Users\amarg\Desktop\amar

Before we get started, keep in mind:

  * You are initializing in an existing Firebase project directory

? Are you ready to proceed? Yes
? What Firebase CLI features do you want to setup for this folder? Hosting: Configure and deploy Firebase Hosting sites


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

i  .firebaserc already has a default project, skipping

=== Hosting Setup

Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.

? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? No
? File public/404.html already exists. Overwrite? No
i  Skipping write of public/404.html
? File public/index.html already exists. Overwrite? No
i  Skipping write of public/index.html

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

+  Firebase initialization complete!

C:\Users\amarg\Desktop\amar>firebase deploy

=== Deploying to 'learningweb-6b2a3'...

i  deploying hosting
+  database: rules ready to deploy.
i  hosting: preparing public directory for upload...

Error: An unexpected error has occurred.

C:\Users\amarg\Desktop\amar>

6 回答

  • 0

    对我来说,更新firebase-tools解决了这个问题

    在cmd提示符下运行命令

    npm install -g firebase-tools
    

    然后再次尝试firebase init

  • 1

    是的我遇到了这个问题..这是因为我使用的节点版本 Node v.8.0.0 我只是将其降级为 Node v.16.0.3 然后我的部署完成了:)

  • 1

    Copy this and paste inside of firebase.json

    {
        "hosting": {
          "public": "./",
          "ignore": [
            "firebase.json",
            "database-rules.json",
            "storage.rules",
            "functions"
          ],
          "headers": [{
            "source" : "**/*.@(js|html)",
            "headers" : [ {
              "key" : "Cache-Control",
              "value" : "max-age=0"
            } ]
          }]
        }
      }
    
  • 0

    在我的情况下,解决:

    firebase deploy --except functions
    
  • 1

    当我没有运行 npm install 时,我收到了这个错误 . 试试看 . 我希望简单的解决方案可以帮助任何有同样问题的人 .

  • 3

    这可能是由于npm和节点版本对于mac os,你可以使用命令更新npm:

    npm install -g npm@latest
    

    并通过链接https://nodejs.org/en/直接更新节点并下载安装程序 . 并运行

    npm install -g firebase-tools
    

    要删除firebase托管部署错误(如果您要更新现有托管站点),您可以再次进行处理1] firebase login 2] firebase init 3] firebase deploy

    确保您当前的文件夹有两个东西:公用文件夹(包含所有文件index.html)和firebase.json文件

相关问题