Module has no exported member 'IonicNativePlugin', Ionic2 for 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] 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 {

-- 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 --

<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 --

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 {}

Answers


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.

Save yourselves with this.

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

Did run into same problem and got it working by upgrading @ionic-native/core dependency to latest version (at this time to 3.6.1).


Run the below and after this you need to add provider in app.module.ts file.

npm install @ionic-native/core --save

In your package.json (in the project root folder), get rid of ^ in front of the version. So if you have something like "@ionic-native/core": "^3.4.2", change it to "@ionic-native/core": "3.4.2".

Save the file, and run npm instal and then ionic serve.


Need Your Help

How can I get the utc offset in Rails?

ruby-on-rails ruby datetime timezone

I need the utc offset from the timezone specified.

Building a LINQ expression tree: how to get variable in scope

c# .net linq lambda expression-trees

I'm building a LINQ expression tree but it won't compile because allegedly the local variable $var1 is out of scope: