Search code examples
flutterfirebase-hostingfirebase-tools

Can't build and deploy a flutter web app to firebase hosting after updating firebase-tools


I have a flutter web app that runs locally on my machine when I give the command:

flutter run -d chrome

I was able to build and deploy using the following two commands:

flutter build web
firebase deploy --only hosting

I upgraded my flutter and firebase-tools and after, I can no longer successfully deploy my to firebase hosting.

My index.html is as follows:

  <!DOCTYPE html>
<html>
<head>
  <!--
    If you are serving your web app in a path other than the root, change the
    href value below to reflect the base path you are serving from.

    The path provided below has to start and end with a slash "/" in order for
    it to work correctly.

    For more details:
    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

    This is a placeholder for base href that will be replaced by the value of
    the `--base-href` argument provided to `flutter build`.
  -->
  <base href="$FLUTTER_BASE_HREF">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="qsportsgame">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png"/>

  <title>qsportsgame</title>
  <link rel="manifest" href="manifest.json">
</head>
<body>
  <script src="flutter_bootstrap.js" async></script>
</body>
</html>

After I build and deploy, I am getting the following error on my production site:

Screenshot of my error

Because I can run the code locally, I am inclined to think there is something wrong with the flutter_bootstrap.js. But I have no idea how to diagnose this problem because I can't replicate it on my local computer. Any help with how to proceed would be greatly appreciated.


Solution

  • Figured I'd rather downgrade for now:

    npm uninstall -g firebase-tools

    Then...

    npm install -g [email protected]

    Or any other version than the latest from https://www.npmjs.com/package/firebase-tools?activeTab=versions

    Then...

    flutter clean && flutter pub get && flutter build web && firebase deploy

    And you're back online.

    Sorry for the ugly layout of this answer, but I'm on mobile right now. Good luck!