Solvedangularfire 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

23 Answers

✔️Accepted Answer

@jamesdaniels Yes.
npm install rxjs@6 rxjs-compat@6 --save

It solved the issue.

Other Answers:

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:28 which is of(false); of being imported from rxjs/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.9
I also happen to use Ionic v3

Related Issues:

251
angularfire Missing exported members after updating to Angular 6.0.0
It looks like rxjs-compat is missing Use npm i rxjs-compat to install the missing rxjs-compat. ...
184
angularfire ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase
@jamesdaniels Yes npm install rxjs@6 rxjs-compat@6 --save It solved the issue. I want to use firebas...
164
angularfire @firebase/firestore: Firestore (5.8.0): timestampsInSnapshots
eg: app.module.ts Version info Angular: 7.2.1 Firebase: 5.8.0 AngularFire: 5.1.1 In the newest fireb...
142
angularfire 5.2.1 AngularFireAuthGuard causes TypeError: source.lift is not a function
I worked in this way Performing basic docs for AngularFireAuthGuard produces an error related to sou...
60
angularfire Just get the value once with no subscription
Use .take(1) which will kill the subscription once the first value has emitted. ...
46
angularfire [ERROR] Class 'FirebaseApp' incorrectly implements interface 'App'
Just to be super clear $ ionic cordova run browser Running app-scripts build: --platform browser --t...
46
angularfire Build error: This module is declared with using 'export ='
I see.. What happens when you add these entries to compilerOptions in tsconfig? ...
44
angularfire How to order by date?
Hey guys I just implemented a solution also to this using the mapping function this will return an O...
39
angularfire Namespace 'firebase' has no exported member 'Promise'.
Hey @dauledk! firebase.Promise was removed in version 4.5.0 of the firebase SDK Now you just use a r...
33
angularfire CollectionReference.doc function path should be optional
I agree this should align with the Firebase SDK A potential workaround is to use a pattern like this...
29
angularfire Cannot find namespace 'firebase'.
I am using angularfire2 in an ionic 2 project and I was getting the same error With the new angularf...
25
angularfire Firebase Storage is not working with ionic 3 & AngularFire 4.0.0 rc
Hey guys I was having this same problem but getting an issue where it was saying that my Firebase ap...
25
angularfire Calling AngularFireFunctions.httpsCallable results to error 404 because
The issue seems to come from #1920 (this file) resolving #1874 To get around it for now you can do t...
23
angularfire auth.login() Error "location.protocol" must be http or https
does it make sense to add some Help Wanted! or other label to raise the importance/severity? looks l...
22
angularfire Ducumentation Issues
@Anystrous Update: I see the problem The docs need this fix: We had breaking changes in version 5.0 ...
21
angularfire Cannot read property 'FacebookAuthProvider' of undefined - 2.0.0-beta.5
@arielcessario this works for me too as a workaround Hello Since I have updated my angularfire2 to t...
19
angularfire automaticDataCollectionEnabled' is missing in type 'FirebaseApp'
Same issue solved as suggested above.. At first Version info Angular: 5.2.9 Firebase: ^4.13.0 Angula...
17
angularfire Angular Ivy 9.0 stable and angularfire RC1 using Firestore have trouble with Universal
I am aiming to achieve success bundling us with Angular 9 SSR within a week Depending on the day of ...
16
angularfire Unhandled Promise rejection: this._next is not a function : Zone in @angular/fire/messaging
this worked for me: When I am receiving firebase push notifications in the foreground by using @angu...
15
angularfire Feature Request: Official version to delete a collection and all nested documents
There's no angularfire version You'd have to access the native Firestore SDK references: The above e...
15
angularfire FireStore timestampsInSnapshots
you can try but i dont know if it work : and comment: AngularFirestoreModule.enablePersistence() ...
15
angularfire Module '"/node_modules/angularfire2/angularfire2"' has no exported member 'AngularFireModule'.
@lfarroco @DMPS Can you try the pre-release version? I am trying to use the latest version of Angula...
13
angularfire How do I iterate through FirebaseListObservable<[]> object
Hi As this.users will get its data asynchronously from firebase you're likely trying to iterate befo...
11
angularfire AngularFire is not compatible with Firebase JS SDK v8
I still can't get auth and User by importing firebase/app It just says it doesn't have an exported m...
10
angularfire Can't run npm install angularfire2 firebase --save
I believe this issue is due to the latest version of firebase is now 4.0.0 but angularfire2@4.0.0-rc...
8
angularfire signInWithCredential error code auth/network-request-failed
Hi I have had the same problem with signInWithCredential which returns an error code auth/network-re...
6
angularfire Server Error. certificate has expired
I'm not super familiar with AngularFire but I'm pretty sure I found the issue ** Screenshots ** Expe...
3
angularfire Uncaught Error: "location.protocol" must be http or https when building to device using Ionic 2 & Angular 2
here is a project where I am running into issues - https://github.com/aaronksaunders/ionic2-angularf...
885
components Error: mat-form-field must contain a MatFormFieldControl.
You have to add to app.module.ts: Bug feature request or proposal: When doing a karma/jasmine test I...
608
angular Angular5.x lazyLoad problem, undefined is not a function
For others that find this issue via Google as i did: I had the same problem when trying to lazy load...
348
angular Cyclic dependency error with HttpInterceptor
I resolved simply not setting authService in constructor but getting in the intercept function. ...
286
angular cli Issue: Cannot read property 'thisCompilation' of undefined
Here is the answer from issues #9793 : npm remove webpack npm install webpack@3.11.0 ...
277
angular Uncaught Error: Can't resolve all parameters for ...
You are missing an @Injectable() annotation on your ApiService Support requests like these should li...
275
ngx bootstrap fix(tooltip): tooltip flickering when hover the mouse on the border on the tooltip position
Add pointer-events: none; to the tooltip css problem solved! .tooltip { pointer-events: none; } ...
266
angular Force reload/refresh current route with RouteReuseStrategy
Hi If you really need to trick the Router into reloading the component on each routerLink click ...
260
angular Misleading error message "Cannot find a differ supporting object '[object Object]'"
I just ran into the same issue I'm not sure if the recommended solution will work for my case ...
255
angular cli Error | Could not find plugin "proposal-numeric-separator" | Generating ES5 bundles for differential loading
Try to install @babel/compat-data: ~7.8.0 to devDependencies This is the only workaround which helpe...
246
sheetjs How to simply export a Worksheet to xlsx?
There are two issues: each object is mapped to a row so if you want a row with name John and city Se...
236
angular cli Using invalid environment causes error in build (was "ERROR in Cannot read property 'length' of undefined")
Probably not the same cause but we had the same error (Cannot read property 'length' of undefined) w...
232
angular cli ng serve method ip not open in another machines
The solution is simple Just bind to the correct interface address via ng serve --host=0.0.0.0 ...
226
angular cli Incorrect JS paths when ng build -prod is deployed in a subfolder
When you're deploying to non-root path within a domain you'll need to manually update the <base href...
224
angular update 2 to 4 has problem [ts] Property 'map' does not exist on type 'Observable<Response>'.
I met the same problem with the angular cli 6.0.0 and rxjs 6.1.0 And I solved the problem by replaci...
218
angular cli Installation error: permission denied for node-sas
sudo npm install -g --unsafe-perm --verbose @angular/cli Installation error (node-sass) with: node v...
208
angular cli ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
Instead of use ng build --prod use ng build --env=prod UPDATE As many of us (thx) have mention this ...
175
storybook Webpack 4 support?
I'm getting the below error when running Storybook with a project using Webpack 4; This is preventin...
173
angular cli Property 'controls' does not exist on type 'AbstractControl'.
Got it! Looked at the docs - FormArray The FormArray class contains the controls property ...
170
angular Angular2 AoT Compiler Errors
pls try /cc @chuckjaz When I try to compile my project with ngc it throws the below error: Error: Er...
167
angular cli [Bug] cli needs to be reloaded when a lazy loaded module is added in routes (FIXED)
I recomended change { path: 'user-panel' loadChildren: './user-panel/user-panel.module#UserPanelModu...
167
prettier Change HTML/JSX formatting to have one attribute/prop per line
The point I am trying to make is that the vertical space matters Wasting it (too much) has negative ...
162
angular cli AOT build fails
I noticed same problem and after npm i enhanced-resolve@3.3.0 I can build with AOT ...