ng: error in production with Cb(...).firestore is not a function

Viewed 522

I have a problem when I use a production mode with firestore.

ERROR Error: Uncaught (in promise): TypeError: Cb(...).firestore is not a function TypeError: Cb(...).firestore is not a function

when I am serving in dev mode everything works fine.

I am using "@angular/fire": "^5.2.1","firebase": "^6.2.3",

my environment is the same in dev and prod jst production is true.

When I do ng build without --prod it works fine when I do ng build --prod the error occurs. The firebase was working properly than I added fire/storage with some image manipulation

I really don't know which part of code to show. Because I don't know where can be the problem. :-(

TypeError: Cb(...).firestore is not a function
TypeError: Cb(...).firestore is not a function
    at firestore.js.pre-build-optimizer.js:39
    at e.invoke (zone.js.pre-build-optimizer.js:391)
    at t.run (zone.js.pre-build-optimizer.js:150)
    at t.runOutsideAngular (core.js.pre-build-optimizer.js:17257)
    at new t (firestore.js.pre-build-optimizer.js:37)
    at core.js.pre-build-optimizer.js:21272
    at Ki (core.js.pre-build-optimizer.js:21234)
    at Wi (core.js.pre-build-optimizer.js:21198)
    at core.js.pre-build-optimizer.js:21266
    at Ki (core.js.pre-build-optimizer.js:21234)
    at P (zone.js.pre-build-optimizer.js:831)
    at P (zone.js.pre-build-optimizer.js:788)
    at zone.js.pre-build-optimizer.js:892
    at e.invokeTask (zone.js.pre-build-optimizer.js:423)
    at Object.onInvokeTask (core.js.pre-build-optimizer.js:17289)
    at e.invokeTask (zone.js.pre-build-optimizer.js:422)
    at t.runTask (zone.js.pre-build-optimizer.js:195)
    at g (zone.js.pre-build-optimizer.js:601)
vn @ core.js.pre-build-optimizer.js:15723
2 Answers

I had the same issue with AngularFirestore (working in dev, not working in prod), even though it was in the app.module.ts->@NgModule->providers. Turns out a respective AngularFirestoreModule must be in @NgModule->imports.

The problem was I didn`t add angularfirestorage to app.module. I dont know why it made problems just in production but that was it.

Related