Skip to content

ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase #1668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zediz opened this issue May 17, 2018 · 24 comments

Comments

@Zediz
Copy link

Zediz commented May 17, 2018

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

@jaufgang
Copy link

Same here. I am getting this error on a previously working project after upgrading angularfire2 from rc.4 to rc.9

@devsmitra
Copy link

I'm also getting same after updating to rc.9 also.

@hgchrre
Copy link

hgchrre commented May 17, 2018

Same here after updating to rc.9
I also happen to use Ionic v3

@diego-lipinski-de-castro

Same here

@jaufgang
Copy link

Help us @davideast, you're our only hope!

@diego-lipinski-de-castro

This comment has been minimized.

@jamesdaniels
Copy link
Member

jamesdaniels commented May 17, 2018

@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?

@diego-lipinski-de-castro

This comment has been minimized.

@jamesdaniels
Copy link
Member

@diego-lipinski-de-castro let's please keep the conversation to the error at hand.

@jamesdaniels
Copy link
Member

Closing for now, since I'm 99% sure that's what the issue is.

@diego-lipinski-de-castro

Yeah, solved this issue, the problem now is with rxjs => Cannot find module "rxjs-compat/Observable"

@jamesdaniels
Copy link
Member

@diego-lipinski-de-castro are you the one trying to import Observable or is it a lib? Observable can be imported from rxjs: import { Observable } from 'rxjs', if it's not you including you'll want to hunt down the library having troubles and file bugs with them.

@jamesdaniels
Copy link
Member

For reference here's the RXJS 5 => 6 migration guide.

@diego-lipinski-de-castro

I needed to install rxjs-compat, after that I updated all packaged and it's working

@Nox04
Copy link

Nox04 commented May 18, 2018

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

It solved the issue.

@vandres
Copy link

vandres commented Sep 11, 2018

Will it be possible to use this library also without rxjs-compat?

@OliveIT
Copy link

OliveIT commented Jan 13, 2019

Thank you, Nox04.

@jhonnathanH
Copy link

thx Nox04 u save me

calcooke pushed a commit to calcooke/Ionic-maps-firebase-and-API that referenced this issue Apr 5, 2019
In order to build out my app, I had to update angular fire from rc6 to
[email protected]. Now there an error when using firestore:
"TypeError: Object(...) is not a function at new AngularFirestore".

The solution is likely to do with rxjs:
angular/angularfire#1668

My current RXJS is "rxjs": "5.5.2".
@JoAlgorithm
Copy link

@Nox04 am facing this issue after install rxjs, can u help me pls ???

in ../../node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ';' e xpected.
../../node_modules/rxjs/internal/types.d.ts(81,74): error TS1005: ';' expected

@Fjnova
Copy link

Fjnova commented Sep 18, 2019

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
],

@ValiHar
Copy link

ValiHar commented Oct 15, 2019

@Fjnova Thanks, had the same issue with production mode and that solved it!

@imvikaskohli
Copy link

imvikaskohli commented Nov 6, 2019

@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
],

@arnaudelub
Copy link

In 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

@lucianobrunet
Copy link

Thanks @Fjnova, I was crazy trying to find the solution to this problem, finally I was missing the importation of AngularFireAuthModule and AngularFirestoreModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests