[英]When integrating angular/fire 7.5 with angular 15, get error Need to provide options, when not being deployed to hosting via source
I am porting an app from angular8 with angular/fire 5.4 to angular15 with angular/fire 7.5.我正在将一个应用程序从具有 angular/fire 5.4 的 angular8 移植到具有 angular/fire 7.5 的 angular15。 I added the following to my AppModule imports section
我将以下内容添加到我的 AppModule 导入部分
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { provideFirestore, getFirestore } from '@angular/fire/firestore';
import { provideStorage, getStorage } from '@angular/fire/storage';
import { provideAuth, getAuth } from '@angular/fire/auth';
import { provideFunctions, getFunctions } from '@angular/fire/functions';
imports: [
...
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireStorageModule,
AngularFirestoreModule,
AngularFireAuthModule,
AngularFireFunctionsModule,
provideFirebaseApp(() => initializeApp(environment.firebaseConfig)),
provideAuth(() => getAuth()),
provideFirestore(() => getFirestore()),
provideStorage(() => getStorage()),
provideFunctions(() => getFunctions()),
...
],
providers: [
{ provide: FIREBASE_OPTIONS, useValue: environment.firebaseConfig }
]
But I am getting this error message: What am I missing?但我收到此错误消息:我错过了什么?
main.ts:14 FirebaseError: Firebase: Need to provide options, when not being deployed to hosting via source. (app/no-options).
at initializeApp (index.esm2017.js:423:29)
at getApp (index.esm2017.js:476:16)
at getFunctions (index.esm2017.js:666:35)
at angular-fire.js:227:48
at angular-fire.js:160:59
at _ZoneDelegate.invoke (zone.js:372:26)
at Zone.run (zone.js:134:43)
at NgZone.runOutsideAngular (core.mjs:24212:28)
at runOutsideAngular (angular-fire.js:160:35)
at angular-fire.js:227:21
```
I figured it out.我想到了。 I had a service which used AngularFireAuth but was not imported from the compat folder.
我有一个使用 AngularFireAuth 但不是从 compat 文件夹导入的服务。 So while it compiled, it gave me that error during runtime.
因此,在编译时,它在运行时给了我那个错误。 So if you use the compat mode of angularfire use it everywhere
因此,如果您使用 angularfire 的兼容模式,请在任何地方使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.