部署到 Firebase 托管时无法初始化 Firebase 存储

Cannot initialize Firebase Storage when deployed to Firebase Hosting

我有一个托管在 firebase 主机上的应用程序,当 运行 在我的本地服务器上时可以运行,但是当我部署它时,firebase 存储无法初始化。

<script src="node_modules/firebase/firebase-app.js"></script>
<script src="node_modules/firebase/firebase-auth.js"></script>
<script src="node_modules/firebase/firebase-firestore.js"></script>
<script src="node_modules/firebase/firebase-functions.js"></script>
<script src="node_modules/firebase/firebase-storage.js"></script>
<script>
var config = {
  apiKey: "<my key>",
  authDomain: "<my domain>",
  databaseURL: "<my url>",
  projectId: "<my id>",
  storageBucket: "<my bucket>",
  messagingSenderId: "<my id>"
};
firebase.initializeApp(config);
var db = firebase.firestore();  <-- this works
var storage = firebase.storage();  <-- this doesn't
</script>

我也在使用其他服务,没有问题,除了存储线外,部署版本和本地版本之间的功能没有差异。

从控制台调用它时我得到

firebase-storage.js:1 
Uncaught TypeError: Cannot read property 'path' of null
at Function.t.makeFromBucketSpec (firebase-storage.js:1)
at Function.t.extractBucket_ (firebase-storage.js:1)
at new t (firebase-storage.js:1)
at new t (firebase-storage.js:1)
at Object.storage (firebase-storage.js:1)
at t._getService (firebase-app.js:1)
at t.ur.(/anonymous function) [as storage] (<my url>/esm-bundled/node_modules/firebase/firebase-app.js:1:34079)
at Object.f [as storage] (firebase-app.js:1)
at <anonymous>:1:10

我能够使用库的托管版本解决这个问题

<script src="https://www.gstatic.com/firebasejs/5.2.0/firebase-storage.js"></script>