11

I am new to Angular 4, so I am creating a firebase chat app with Angular 4, and then when I import some modules like this:

import { AngularFire, AuthProviders, AuthMethods,FirebaseListObservable } from 'angularfire2';

I get an error for each module that says

Has no exported member AngularFire, AuthProviders, AUthMethods, FirebaseListObservable.

Thank you

Pengyy
  • 37,383
  • 15
  • 83
  • 73
Jośe
  • 125
  • 1
  • 2
  • 10

3 Answers3

20

UP TO DATE(Ver 5.0.0-rc3):

While getting this error, this means you are using old Database API. This can solved by importing FirebaseListObservable from depracated module(See also @Ashish Jha answer):

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database-deprecated';

It's recommended to use the latest API since AngularFire 5.0 brings new API for the Realtime Database. Refer upgrade guide.


ORIGINAL ANSWER: AngularFire2 has separate its modules since 4.0.0+.

you can import those two module if you want use auth of angularfire2, see their change log :

import {AngularFireModule} from 'angularfire2';
// for auth    
import {AngularFireAuthModule} from 'angularfire2/auth';
// for database
import {AngularFireDatabaseModule} from 'angularfire2/database';

and import Auth and Observable(AuthMethods can be found in AngularFireAuth) type by:

// for auth
import { AngularFireAuth } from 'angularfire2/auth';
// for database
import { AngularFireDatabase } from 'angular2/database';
// for Observables
import {FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
Pengyy
  • 37,383
  • 15
  • 83
  • 73
  • How about the rest, that is shown in my question. Now, FirebaseListObservable has exported, but the rest "AngularFire, AuthProviders, AuthMethods" are not exported. And Also, when I hit ng serve in terminal to see my app. I get an error: "The "@angular/compiler-cli" package was not properly installed." – Jośe May 16 '17 at 01:58
  • 1
    With a little effort you can find those others now too... Just look in the changelog provided here. The angular compiler-cli you can install like: npm install --save-dev @angular/compiler-cli – therebelcoder May 16 '17 at 02:03
  • @stevenvanc when doing "npm install --save-dev @angular/compiler-cli " I get UNMET PEER DEPENDENCY @angular/compiler. – Jośe May 16 '17 at 02:07
  • @Pengyy is getting a UNMET PEER DEPENDENCY @angular/compiler – Jośe May 16 '17 at 02:11
  • @Jośe run `npm install --save-dev @angular/compiler-cli` too. also when you are done with your project run `npm install -g @angular/cli@latest` too – Pengyy May 16 '17 at 02:13
  • @Pengyy Update your answer ASAP, its not working for the latest version. This is more preferable import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated"; – Rijo Oct 17 '17 at 01:39
  • @Rijo thanks for your comment. In order to not confuse others who are looking for help here with old version, I just updated to include the deprecated version and also add a upgrade guide for the latest version of angularfire2. – Pengyy Oct 17 '17 at 01:58
  • 2
    Okay, I am using "angularfire2": "^5.0.0-rc.3" for this i can't import import {FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database'; showing as error – Rijo Oct 17 '17 at 02:10
  • @Rijo see my **up to date** part. You should import them from `angularfire2/database-deprecated`. – Pengyy Oct 17 '17 at 02:14
8

The solution that worked for me was to change this line

import { AngularFire, AuthProviders, AuthMethods,FirebaseListObservable } from 'angularfire2'; 

to

import { AngularFireAuth } from 'angularfire2/auth';

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated";

You can read more about it here https://github.com/angular/angularfire2/blob/master/CHANGELOG.md

thedreamsaver
  • 1,294
  • 4
  • 16
  • 27
  • 2
    ahhhrrr!! all those too fast changes..... same mess with firebase, same mess with material. THX ALOT – bresleveloper Oct 06 '17 at 12:35
  • You're welcome. The new update uses AngularFirestore and it uses a simple Observable instead of FirebaseListObservable. This thing bugged me for quite a bit too. – thedreamsaver Oct 06 '17 at 19:49
0

use AngularFireObject instead of FirebaseObjectObservable and AngularFireList instead of FirebaseListObservable ,this has been updated since AngularFire5

if you want more details checkout https://github.com/angular/angularfire2/blob/master/docs/version-5-upgrade.md

  • Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. See: [How to anwser](https://stackoverflow.com/help/how-to-answer). – Eduardo Baitello Sep 26 '19 at 03:49