希望这对在将 Angular 应用程序部署到 Firestore 时遇到同样问题的人有所帮助。
在 Angular 8 项目中,我在部署到 Firestore 时遇到了同样的错误。我通过添加另一个moduleAngularFirestoreModule 来修复它。
App.module.ts 是这样的:
...
import { AngularFireModule } from '@angular/fire';
import { AngularFirestore, AngularFirestoreModule } from '@angular/fire/firestore'; // << Note AngularFirestoreModule !!!
import { AngularFireDatabaseModule } from '@angular/fire/database';
...
imports: [
BrowserModule,
FormsModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFirestoreModule,
AngularFireDatabaseModule,
...
包.json:
...
"dependencies": {
"@angular/animations": "~8.2.2",
"@angular/common": "~8.2.2",
"@angular/compiler": "~8.2.2",
"@angular/core": "~8.2.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "~8.2.2",
"@angular/platform-browser": "~8.2.2",
"@angular/platform-browser-dynamic": "~8.2.2",
"@angular/router": "~8.2.2",
"ajv": "^6.10.2",
"bootstrap-scss": "^4.3.1",
"core-js": "^2.5.4",
"firebase": "^6.4.0",
...
更新:当我部署到其他托管服务提供商时,这没有帮助。对于这种情况,我添加了原始的 firebase 库并且它起作用了。
import { firestore } from 'firebase';