1

I am creating user registration system using google firebase , I am following this tutorial :

User registration system

NOTE

: am using this version "firebase": "^5.5.6",

When I run my app I have the following errors:

ERROR in src/app/login/login.component.ts(2,10): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/index"' has no exported member 'AngularFire'.
src/app/login/login.component.ts(3,28): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/firestore/index"' has no exported member 'AuthProviders'.
src/app/login/login.component.ts(3,43): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/firestore/index"' has no exported member 'AuthMethods'.

Here is app.modul.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import {HttpClientModule} from '@angular/common/http';
import { UserService } from './service/user.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MomentModule } from 'ngx-moment';
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { LoginComponent } from './login/login.component';
import { EmailComponent } from './email/email.component';
import { SignupComponent } from './signup/signup.component';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { AngularFireDatabaseModule} from 'angularfire2/database';



const firebaseConfig = {
  apiKey: '',
  authDomain: '',
  databaseURL: '',
  projectId: '',
  storageBucket: '',
  messagingSenderId: ''
};


@NgModule({
  declarations: [
    AppComponent,
    UserProfileComponent,
    LoginComponent,
    EmailComponent,
    SignupComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgbModule,
    BrowserModule,
    MomentModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    AngularFireAuthModule,
    BrowserModule,
    AngularFirestoreModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireDatabaseModule,
    HttpModule,
    FormsModule,
    HttpClientModule,
    ReactiveFormsModule,
    RouterModule,
    AppRoutingModule,
  ],
  providers: [UserService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Here is login component other components right just empyt

import { Component, OnInit } from '@angular/core';
import { AngularFire, } from 'angularfire2';
import { AngularFirestore, AuthProviders, AuthMethods, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
import { Router } from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {

  // declare empyt array to hold error data
  error: any;

  constructor(public af: AngularFire, private router: Router) {

  // fucntion to check user authentication
    this.af.auth.subscribe(auth => {
      if (auth) {
        this.router.navigateByUrl('/members');
      }
    });
   }

  // function to login in facebook
  loginFb() {
    this.af.auth.login({
      provider: AuthProviders.Facebook,
      method: AuthMethods.Popup,
    }).then(
      (success) => {
        this.router.navigate(['/members']);
    }).catch(
      (err) => {
        this.error = this.error;
      });
  }

    // function to login with google
    loginGoogle() {
      this.af.auth.login({
        provider: AuthProviders.Facebook,
        method: AuthMethods.Popup,
      }).then(
        (success) => {
          this.router.navigate(['/members']);
      }).catch(
        (err) => {
          this.error = this.error;
        });
    }

  ngOnInit() {
  }

}

I have used almost all solution in stack overflow but nothing worked , I am about to give up now , I dont see any good documentation on this for dummies to understand what the hell is going on :(

What do I need to change to get rid of this error?? please help

The Dead Man
  • 6,258
  • 28
  • 111
  • 193
  • 1
    which firebase release do you use ? – Jake11 Oct 31 '18 at 12:32
  • @Jake11 "firebase": "^5.5.6", – The Dead Man Oct 31 '18 at 12:48
  • so version they used in tut is ~3.6.5, you can try to downgrade to it, or try to follow releases notes https://firebase.google.com/support/release-notes/js to find out where those classes has been moved, or just search in docs where can you find them for version that you are using. – Jake11 Oct 31 '18 at 12:53
  • 1
    if you decide to downgrade i am not sure but you propably will have to also downgrade angularfire2 to older version – Jake11 Oct 31 '18 at 12:55
  • umfortunately downgrading the firebase still have errors and many others erros comes in – The Dead Man Oct 31 '18 at 13:03

1 Answers1

1

Tutorial is from Jan 17, 2017 and if you run npm install angularfire2 firebase --save you will have latest version of firebase installed, which is not the one tutorial is based on, look here is similar post on this problem

So you have to etiher downgrade firebase version, which you use for this project or upgrade imports so their point to right files, in which you can find classes you need

Jake11
  • 801
  • 2
  • 11
  • 24
  • jake I tried all this souliton but none works :( that is why I needed some help – The Dead Man Oct 31 '18 at 12:57
  • @user9964622 and whats version of angularfire2 do you have ? – Jake11 Oct 31 '18 at 13:03
  • "angularfire2": "^5.1.0",? – The Dead Man Oct 31 '18 at 13:04
  • 1
    @user9964622 run `npm remove angularfire2` -> `npm install angularfire2@2.0.0-beta.7 --save` -> `npm remove firebase` -> `npm install firebase@3.6.5 --save` -> restart app -> tell me if error is still occuring – Jake11 Oct 31 '18 at 13:14
  • now I get this error : `'subscribe' does not exist on type 'AngularFireAuth'.` – The Dead Man Oct 31 '18 at 13:25
  • update whole package.json so it looks same as here https://github.com/designcourse/angular-auth-demo/blob/master/package.json , run `npm update`, and restart project, try `npm install` if `npm update` wont help – Jake11 Oct 31 '18 at 13:36