angular - ionic 3 :Type 'any' is not a constructor function type

标签 angular ionic2 native node-modules ionic3

当我应付并转移到具有 ionic 3 的 mac 时,我在我的 linux 任务中有我的 ionic 2 项目。

所以我创建了一个新项目并用新项目替换了 pages、provides、components 文件夹,在将我的插件导入 app.modulte 后,我收到了类似 cannot find module "ionic-native" 的错误.ts 文件我收到错误消息,因为“Type 'any' is not a constructor function type”。`

我的终端显示

17:39:48]  typescript: node_modules/@ionic-native/app-version/index.d.ts, line: 25
            Type 'any' is not a constructor function type. [17:39:48]  typescript: node_modules/@ionic-native/geolocation/index.d.ts, line: 127 [17:39:48]  typescript: node_modules/@ionic-native/google-analytics/index.d.ts, line: 30 [17:39:48]  typescript: node_modules/@ionic-native/network/index.d.ts, line: 49 [17:39:48]  typescript: node_modules/@ionic-native/sms/index.d.ts, line: 41 [17:39:48]  typescript: node_modules/@ionic-native/social-sharing/index.d.ts, line: 29 [17:39:48]  typescript: node_modules/@ionic-native/sqlite/index.d.ts, line: 115

      L25:  export declare class AppVersion extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

     L127:  export declare class Geolocation extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

      L30:  export declare class GoogleAnalytics extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

      L49:  export declare class Network extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

      L41:  export declare class SMS extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

      L29:  export declare class SocialSharing extends IonicNativePlugin {

            Type 'any' is not a constructor function type.

     L115:  export declare class SQLite extends IonicNativePlugin {

[17:39:48]  dev server running: http://localhost:8100/

在我的浏览器中,我收到类似 this 的错误

这是我的 package.json 文件

{
  "name": "ionic-hello-world",
  "version": "0.0.0",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.2",
    "@angular/compiler": "4.0.2",
    "@angular/compiler-cli": "4.0.2",
    "@angular/core": "4.0.2",
    "@angular/forms": "4.0.2",
    "@angular/http": "4.0.2",
    "@angular/platform-browser": "4.0.2",
    "@angular/platform-browser-dynamic": "4.0.2",
    "@ionic-native/app-version": "^3.6.1",
    "@ionic-native/geolocation": "^3.6.1",
    "@ionic-native/google-analytics": "^3.6.1",
    "@ionic-native/network": "^3.6.1",
    "@ionic-native/sms": "^3.6.1",
    "@ionic-native/social-sharing": "^3.6.1",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/sqlite": "^3.6.1",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.1.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.5"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.6",
    "typescript": "~2.2.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard",
    "cordova-plugin-android-permissions",
    "cordova-plugin-app-version",
    "cordova-plugin-geolocation",
    "cordova-plugin-google-analytics",
    "cordova-plugin-network-information",
    "cordova-plugin-sms",
    "cordova-plugin-x-socialsharing",
    "cordova-sqlite-storage"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],
  "description": "kmart: An Ionic project"
}

在使用 npm install @ionic-native/core --save 之后,我收到类似 this 的错误

最佳答案

要使用ionic-native 3.x,您需要安装@ionic-native/core

npm install @ionic-native/core@3.6.1 --save

关于angular - ionic 3 :Type 'any' is not a constructor function type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43759991/

相关文章:

php - Angular 2 : receiving data from php file

Angular 库 : configure exported members

javascript - ngIf 和 @Input angular2 奇怪的行为

javascript - Ionic 2 InAppBrowser 不会加载插入的链接

mobile - 在网络应用程序 (Angular2) 和移动应用程序 (Ionic 2) 之间共享代码

java - 原生 Float.floatToRawIntBits(float value) 的输出是什么?

ios - Cordova-ios 中的状态栏保持半透明

javascript - Json服务器: Error: Insert failed,重复ID

Angular2/Ionic2::重新加载组件

multithreading - java 8中javaw进程的私有(private)字节增加