angularfire: ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase
I want to use firebase and angularfire2 in my app, first of all, I installed them, and for the declarations:
in environment.ts
export const environment = {
production: false,
firebase: {
apiKey: 'sfsdfdsff',
authDomain: 'sfsdfdf',
databaseURL: 'https://ng-sfsdfsf.firebaseio.com',
projectId: 'ng-fitnesssfsdfdsf',
storageBucket: 'ng-fsdfsdfsfdecff5.appspot.com',
messagingSenderId: '21331323'
}
};
in app.module.ts, imports:
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule
in the component where want to get my data:
import { AngularFirestore } from 'angularfire2/firestore';
until this moment I have not an error, but when I want to declare my variable in the constructor to use it:
constructor(private trainingService: TrainingService, private
db:AngularFirestore) { }
I have an error:
ERROR TypeError: Object(...) is not a function
at eval (firestore.js:28)
at ZoneDelegate.invoke (zone.js:388)
at Zone.run (zone.js:138)
In my package.json:
"angularfire2": "^5.0.0-rc.8.0",
"core-js": "^2.4.1",
"firebase": "^5.0.2",
and I don’t know why?
thanks for your help
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 19
- Comments: 24 (5 by maintainers)
@jamesdaniels Yes.
npm install rxjs@6 rxjs-compat@6 --saveIt solved the issue.
with me, it happend when I built with mode production. I can fix it by adding the bold line:
imports: [ CommonModule, SharedModule, AngularFireModule.initializeApp(environment.firebaseConfig), AngularFireStorageModule ],
@Zediz your stacktrace mentions
firestore.js:28which isof(false);ofbeing imported fromrxjs/observables. What version of RXJS are you using? RCs 8 & 9 are only compatible with RXJS 6.Can anyone else on the thread can confirm if this is the issue?
Same here after updating to
rc.9I also happen to use Ionic v3In my case the error was Object(…).auth is not a function, so adding the AngularFireAuthModule solved the issue and production build is now working, thank you to @Fjnova for the hint
@Fjnova you are genius I have resolved that issue too but the module name is different AngularFireDatabaseModule
import { AngularFireDatabase, AngularFireDatabaseModule } from ‘@angular/fire/database’;
imports: [ CommonModule, AngularFireModule.initializeApp(environment.firebase, ‘namespace’), AngularFireDatabaseModule, CustomPipeModule, FormsModule, HomeRoutingModule, ChartsModule, OwlModule, AppMatDialogModules ],
Thanks @Fjnova, I was crazy trying to find the solution to this problem, finally I was missing the importation of AngularFireAuthModule and AngularFirestoreModule