Error on integrating of Ionic2 Auth service

烈酒焚心 提交于 2019-12-11 08:44:41

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/44428177/error-on-integrating-of-ionic2-auth-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!