集成Ionic2 Auth服务时出错 [英] Error on integrating of Ionic2 Auth service

查看:108
本文介绍了集成Ionic2 Auth服务时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将facebook登录集成到我的离子2应用程序中。我按照指南

解决方案

package.json 中包含无效的包。

 ionic-native:^ 3.5.0,

从版本3.x开始,
ionic-native 分为 @ ionic-native / core @ ionic-native / package_name .So ionic-native 3.x 不存在。



删除ionic-native:^ 3.5.0,从package.json输入。



清除node_modules文件夹并运行 npm install



同样在我的评论中提到:
需要o再次将Auth设置为提供者。它将由云模块


处理

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

这篇关于集成Ionic2 Auth服务时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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