/ angularfire2 / index没有导出的成员' AngularFire'

时间:2017-05-04 08:30:59

标签: angular firebase import angular-cli angularfire2

无法解决此问题:

app.component.ts

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

/angularfire2/index has no exported member 'AngularFire',
/angularfire2/index has no exported member 'AuthProviders',
/angularfire2/index has no exported member 'AuthMethods '

但在app.module.ts

import { AngularFireModule } from 'angularfire2';

工作正常,我可以初始化应用

的package.json

"angularfire2": "^4.0.0-rc.0",
"core-js": "^2.4.1",
"firebase": "^3.9.0",
...
"devDependencies": {...
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"

3 个答案:

答案 0 :(得分:14)

由于您使用的是angularfire2@4.0.0+,因此不再导出AngularFire。相反,你应该使用如下:

// import AngularFireAuthModule at NgModule
import { AngularFireAuthModule } from 'angularfire2/auth';


import { AngularFireAuth } from 'angularfire2/auth';
// inject 
construstor(afa: AngularFireAuth) {
  afa.auth.signInWithPopup()
}

答案 1 :(得分:1)

升级到AngularFire2 4.0解决了我的问题

迁移指南: https://github.com/angular/angularfire2/blob/master/docs/version-4-upgrade.md

答案 2 :(得分:0)

解决方案是:

使用"angularfire2": "^5.1.1",

您也需要此库:

"rxfire": "^3.3.5",
"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",