简体   繁体   中英

Error on integrating of Ionic2 Auth service

I'm trying to integrate facebook login to my ionic 2 app. I was following the guide here and all is good until I stared to using Auth and User in the constructor.

The problem is , currently when i use public auth: Auth, public user: User in my constructor then it give issue

Uncaught Error: Cannot find module "ionic-native"

Following is my full code

import { Component } from '@angular/core';
import { Auth, User } from '@ionic/cloud-angular';
@Component({
  selector: 'social-auth',
  templateUrl: 'social.html',
})
export class SocialAuth {
  constructor(public auth: Auth, public user: User) {
  }
  openTwitter(){
    this.auth.login('twitter').then((data) => {
     console.log(data);
    });
  }
}

My package json is

{
  "name": "ionic-app-base",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build --rollup ./config/rollup.config.js",
    "minify": "ionic-app-scripts minify --cleancss ./config/cleancss.config.js",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/camera": "^3.10.3",
    "@ionic-native/core": "^3.6.1",
    "@ionic-native/device": "^3.6.1",
    "@ionic-native/file": "^3.6.1",
    "@ionic-native/file-path": "^3.6.1",
    "@ionic-native/geolocation": "^3.6.1",
    "@ionic-native/in-app-browser": "^3.12.1",
    "@ionic-native/paypal": "^3.10.2",
    "@ionic-native/sim": "^3.5.0",
    "@ionic-native/social-sharing": "^3.10.3",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic-native/toast": "^3.6.1",
    "@ionic-native/transfer": "^3.6.1",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.0.1",
    "ionic-debug-console": "^0.1.0",
    "ionic-native": "^3.5.0",
    "ionicons": "3.0.0",
    "moment": "^2.18.1",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "@ionic/cli-plugin-ionic-angular": "1.1.2",
    "typescript": "~2.2.1"
  }
}

and when I am installing ionic clound then this is i am getting :-

在此处输入图片说明

You have an invalid package in your package.json .

"ionic-native": "^3.5.0",

From version 3.x, ionic-native is split into @ionic-native/core and @ionic-native/package_name .So ionic-native 3.x does not exist.

Remove the "ionic-native": "^3.5.0", entry from your package.json.

Clear node_modules folder and run npm install

Also as mentioned in my comment: you dont need to set Auth as provider again..It will be taken care of by the Cloud module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM