angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

TypeError: app.firestore is not a function after updating to firebase 5.5.0

Open mazlano27 opened this issue 8 years ago • 15 comments

Angular: 6.1.7

Firebase: 5.5.0

AngularFire: 5.0.0

** Errors in the JavaScript console ** TypeError: app.firestore is not a function at firestore.js:22 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at NgZone.push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular (core.js:3783) at new AngularFirestore (firestore.js:20) at _createClass (core.js:8431) at _createProviderInstance (core.js:8393) at resolveNgModuleDep (core.js:8356) at _createClass (core.js:8421) at _createProviderInstance (core.js:8393)

** Screenshots ** screen shot 2018-09-17 at 4 05 30 pm

Expected behavior

Angular application should bootstrap successfully.

Actual behavior

Application does not run at all.

I have tried to clean my npm cache, delete all node modules and re-installing all dependencies with no luck. I should note everything was working fine before I upgraded to firebase 5.5.0 and now even when i revert back to previous version 5.4.2 -> I am still getting this error.

Update: Managed to revert back 5.4.2 successfully.

mazlano27 avatar Sep 17 '18 08:09 mazlano27

Hi @mazlano27! Can you show your imports in your app module?

davideast avatar Sep 17 '18 17:09 davideast

Hi @davideast, it's as follows:

imports: [ BrowserModule, BrowserAnimationsModule, MaterialModule, FlexLayoutModule, AngularFireModule.initializeApp(environment.firebase), AngularFirestoreModule, AngularFireAuthModule, Routing, FormsModule, ReactiveFormsModule, HttpClientModule ]

mazlano27 avatar Sep 18 '18 12:09 mazlano27

Hi @mazlano27! What version of rxjs are you running? The new version of AngularFire requires rxjs v6, which was not the case previously.

Wordenskjold avatar Sep 18 '18 15:09 Wordenskjold

@Wordenskjold In this project, i'm using rxjs v6.3.2

mazlano27 avatar Sep 18 '18 15:09 mazlano27

I had the same issue after upgrading firebase to version 5.5.0. I am not fully sure what caused the bug but deleting and regenerating package-lock.json fixed it for me.

andipaetzold avatar Sep 20 '18 22:09 andipaetzold

I've got this problem with 5.5.7. Deleting package-lock.json then npm install did not fix it for me. I'm not using Angular or RxJS. UPDATE: removing node_modules and package-lock.json then npm install did fix it for me

buzzware avatar Nov 06 '18 05:11 buzzware

The solution that works for me is package.json -> dependecies -> "firebase":"^5.5.0"

davvoz avatar Nov 24 '18 10:11 davvoz

I just had a group of students setting up Angular and Firebase and ran across this error. Any word on getting a fix?

What was put in package.json from following the tutorial: "firebase": "^5.8.3", I had them put in: "firebase": "^5.4.2",, delete the node_modlues folder and package-lock.json, and run npm install ` again. It worked like charm.

gildotdev avatar Feb 21 '19 13:02 gildotdev

Bumped into this problem today, also solved it by

  1. Delete node_modules and package-lock.json
  2. npm install again.

By the way, my firebase version is the same 5.9.0 before and after the solution. So... Don't really know what the problem is...

yglin avatar Mar 19 '19 07:03 yglin

@jamesdaniels Was this resolved?

gildotdev avatar Mar 21 '19 22:03 gildotdev

@gilcreque seems like people have found work arounds here or at least have isolated it as a problem out of scope of AngularFire. Probably something with peer deps or node modules just being messed up. Good ol' rm -rf node_modules bugfix. Happy to reopen if we have a repro & can identify the issue is with AngularFire.

jamesdaniels avatar Mar 21 '19 23:03 jamesdaniels

FWIW Firebase JS SDK has had a couple minor issues like this pop up which have been resolved in patches.

jamesdaniels avatar Mar 21 '19 23:03 jamesdaniels

I have the same issue on my heroku server, I cleaned the cache and still the same problem.

ybarbaria avatar Aug 28 '19 12:08 ybarbaria

Just import AngularFirestoreModule, ad it will fix it; I'm using angular 8

imports : [ BrowserModule, BrowserAnimationsModule, HttpClientModule, RouterModule.forRoot(appRoutes), ToastrModule.forRoot(), TranslateModule.forRoot(),

    // Material moment date module
    MatMomentDateModule,

    // Material
    MatButtonModule,
    MatIconModule,

    // Fuse modules
    FuseModule.forRoot(fuseConfig),
    FuseProgressBarModule,
    FuseSharedModule,
    FuseSidebarModule,
    FuseThemeOptionsModule,

    // App modules
    LayoutModule,
    AuthModule,
    UserInfoModule,
    ConnectionsModule,

     // firebase
     AngularFireModule.initializeApp(environment.firebaseConfig),
     **_AngularFirestoreModule,_**
     AngularFireDatabaseModule,
     AngularFireAuthModule,
     DynamicProfileModule
],

cesarvega avatar Sep 03 '19 15:09 cesarvega

Use externalDependencies = [ "@firebase/app", "@firebase/firestore" ] in angular.json file

Below is the code.

"server": { "builder": "@angular-devkit/build-angular:server", "options": { "outputPath": "dist/market-web/server", "main": "server.ts", "tsConfig": "tsconfig.server.json", "externalDependencies": [ "@firebase/app", "@firebase/firestore" ] }, .....

amanjain325 avatar Dec 17 '20 15:12 amanjain325