Search code examples
angularfirebaseangularfire

Module '"@angular/fire/firestore"' has no exported member 'AngularFirestoreModule'


import { AngularFirestoreModule } from '@angular/fire/firestore' ; // => Error

Module '"@angular/fire/firestore"' has no exported member 'AngularFirestoreModule'

package.json

"@angular/fire": "^7.0.4",


Solution

  • I encountered the same problem and in the GitHub repo (https://github.com/angular/angularfire) is explained how to adjust the code for the new version

    import { Firestore, collectionData, collection } from '@angular/fire/firestore';
    import { Observable } from 'rxjs';
    ...
    item$: Observable<Item[]>;
    constructor(firestore: Firestore) {
        const collection = collection(firestore, 'items');
        this.item$ = collectionData(collection);
      }
    

    You also have to change the way you initialize the app in the app.module.ts

    import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
    import { getFirestore, provideFirestore } from '@angular/fire/firestore';
    
    @NgModule({
      imports: [
        provideFirebaseApp(() => initializeApp({ ... })),
        provideFirestore(() => getFirestore()),
      ],
      ...
    })