angularfire 2: Error "Unhandled Promise rejection: TypeError: Cannot read property"

angularfire 2: Error "Unhandled Promise rejection: TypeError: Cannot read property"

我尝试了一个连接到 Firebase 的示例应用程序

在我的 Main.ts 我写了这个:

import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppComponent, environment } from './app/';
import { FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods } from 'angularfire2';

if (environment.production) {
  enableProdMode();
}

bootstrap(AppComponent,[
  FIREBASE_PROVIDERS,
  defaultFirebase({
    apiKey: "MYKEY",
    authDomain: "MYDOMAIN.firebaseapp.com",
    databaseURL: "https://MYDOMAN.firebaseio.com",
    storageBucket: "MYDOMAIN.appspot.com",
  }),
  firebaseAuthConfig({
    provider: AuthProviders.Password,
    method: AuthMethods.Popup
  })
]);

编辑:这里是 component.ts

import { Component } from '@angular/core';
import { LoginComponent } from './login/'

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  directives: [ LoginComponent ]
})
export class AppComponent {
  title = 'Please Login to the App';
}

但是当我使用 "ng serve" 启动我的应用程序并调用 URL 时,我收到一个名为:

的错误

zone.js:461 Unhandled Promise rejection: TypeError: Cannot read property 'FacebookAuthProvider' of undefined at Object.eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:24:43) at eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:108:4) at eval (http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js:109:3) at Object.eval (http://localhost:4200/vendor/angularfire2/angularfire2.js:33:35) Evaluating http://localhost:4200/vendor/angularfire2/providers/firebase_sdk_auth_backend.js Evaluating http://localhost:4200/vendor/angularfire2/angularfire2.js Evaluating http://localhost:4200/app/login/login.component.js Evaluating http://localhost:4200/app/login/index.js Evaluating http://localhost:4200/app/app.component.js Evaluating http://localhost:4200/app/index.js Evaluating http://localhost:4200/main.js Error loading http://localhost:4200/main.js ; Zone: ; Task: Promise.then ; Value: Error: TypeError: Cannot read property 'FacebookAuthProvider' of undefined(…)

有什么想法吗?

根据评论,似乎是在使用 Firebase 2.x SDK 而不是 AngularFire2 所需的 Firebase 3.x SDK 时发生此错误。