离子无法加载插件抛出安装

问题描述 投票:0回答:1

我有一个用离子制作的应用程序我在安装插件时遇到了这个错误

core.js:1449 ERROR TypeError: Object(...) is not a function
    at AppRate.set [as preferences] (index.js:31)
    at MyApp.webpackJsonp.259.MyApp.initializeApp (app.component.ts:32)
    at new MyApp (app.component.ts:19)
    at createClass (core.js:12491)
    at createDirectiveInstance (core.js:12326)
    at createViewNodes (core.js:13784)
    at createRootView (core.js:13673)
    at Object.createProdRootView [as createRootView] (core.js:14366)
    at ComponentFactory_.create (core.js:11278)
    at ComponentFactoryBoundToModule.create (core.js:4030)

在我的情况下,我尝试添加AppRate插件,我在app.modle.ts和app.componets.ts中添加了插件,如下所示的代码

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {enableProdMode} from '@angular/core';
import { AppRate } from '@ionic-native/app-rate/ngx';


@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = 'MenuPage';


  constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, private appRate: AppRate) {
    this.initializeApp();

  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });

    // or, override the whole preferences object
  this.appRate.preferences = {
    usesUntilPrompt: 3,
    storeAppURL: {
    ios: '<app_id>',
    android: 'market://details?id=<package_name>',
    windows: 'ms-windows-store://review/?ProductId=<store_id>'
    }
  }

this.appRate.promptForRating(false);
  }
}
enableProdMode();

我使用离子框架文档来安装插件

ionic cordova plugin add cordova-plugin-apprate
npm install @ionic-native/app-rate

我在安装过程中得到了这个警告

npm WARN @ionic-native/[email protected] requires a peer of rxjs@^6.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/[email protected] requires a peer of @ionic-native/core@^5.1.0 but none is installed. You must install peer dependencies yourself

我从我的mac重新安装了node.js,npm和ionic cordova,但仍然有同样的问题,我在mac os Mojave上使用ionic4。

angular ionic-framework npm cordova-plugins ionic-native
1个回答
0
投票

你需要降级你的app rate插件版本:

nom install @ionic-native/[email protected]

您的插件版本太高(离子5)。

© www.soinside.com 2019 - 2024. All rights reserved.