模块没有导出成员'IonicNativePlugin',Ionic2 for facebook [英] Module has no exported member 'IonicNativePlugin', Ionic2 for facebook

查看:622
本文介绍了模块没有导出成员'IonicNativePlugin',Ionic2 for facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在离子2应用程序中登录facebook,但在构建我的应用程序时出现此错误。
帮我解决这个问题。

am trying to do facebook login in ionic 2 app, but got this error while building my app. help me to solve this.


[13:17:52] transile started ... [13:17:58打字稿:
D:/royalworkspace/newfblogin/node_modules/@ionic-native/facebook/index.d.ts,
行:1
模块'D:/ royalworkspace / newfblogin / node_modules / @ ionic-native / core / index'
没有导出成员
'IonicNativePlugin'。

[13:17:52] transpile started ... [13:17:58] typescript: D:/royalworkspace/newfblogin/node_modules/@ionic-native/facebook/index.d.ts, line: 1 Module '"D:/royalworkspace/newfblogin/node_modules/@ionic-native/core/index"' has no exported member 'IonicNativePlugin'.

   L1:  import { IonicNativePlugin } from '@ionic-native/core';
   L2:  export interface FacebookLoginResponse {


- 主页.ts -

-- Home.ts --

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private facebook: Facebook ) {

  }

  Login(){
    this.facebook.login(['email']).then((Response) =>{
      alert('loged in');
      alert(JSON.stringify(Response.authResponse));
    },(error) => {
      alert(error);
    })
  }
 LoginDetails(){
    this.facebook.getLoginStatus().then((response) => {
      if (response.status == "connected") {
      this.facebook.api('/' + response.authResponse.userID + '?fields=id,name,gender', []).then((response) =>{
          alert(JSON.stringify(response));
        }, (error) =>{
          alert(error);
        })
      }
      else{
        alert('not loged in');
      }         
    })
  }
  Logout(){
    this.facebook.logout().then((Response) => {
      alert(JSON.stringify(Response));
    }, (error) =>{
      alert(error);
    })
  }

}

- - home.html -

-- home.html --

<ion-content padding>
  <button ion-button outline (click)="Login()">Login</button>
 <button ion-button outline (click)="LoginDetails()">Login Details</button>
 <button ion-button outline (click)="Logout()">Logout</button>

</ion-content>

- app.module -

-- app.module --

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,Facebook,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}


推荐答案

IonicNativePlugin在较新版本的离子中添加-native / core,所以我必须卸载这个并安装最新版本的3.6.1,现在插件已经导出,一切正常。

IonicNativePlugin was added in newer version of ionic-native/core, so I had to uninstall this one and install the newest one which is 3.6.1, and now plugin got exported and everything works fine.

保存自己用这个。

npm uninstall --save @ionic-native/core
npm install --save @ionic-native/core@latest

这篇关于模块没有导出成员'IonicNativePlugin',Ionic2 for facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆