/angularfire2/index has no exported member 'An

2019-01-18 04:37发布

问题:

Can't fix this problem:

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 '

but in app.module.ts

import { AngularFireModule } from 'angularfire2';

works fine and I can initialize the app

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"

回答1:

Since you are using angularfire2@4.0.0+, there is no AngularFire exported any more. Instead, you shall use it as below:

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


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


回答2:

Upgrading to AngularFire2 4.0 solve my issue

Migration Guide: https://github.com/angular/angularfire2/blob/master/docs/version-4-upgrade.md