2017-05-03 8 views
3

ich in meinem Linux-Mission mein ionischer 2 Projekt hatte, als ich auf dem Mac fertig geworden und bewegt dieIonic 3: Typ ‚any‘ ist kein Konstruktor Funktion Typ

ionische 3. hat Also habe ich ein neues Projekt und Ersetzte die Seiten, bietet, Komponenten-Ordner mit dem neuen Projekt Ich bekam Fehler wie cannot find module "ionic-native" nach dem Importieren meiner Plugins in app.modulte.ts Datei bekomme ich als Fehler als 'Typ' any 'ist kein Konstruktor-Funktionstyp.'

mein Terminal zeigt

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/ 

in meinem br owser Ich bin Fehler immer wie this

hier ist meine package.json Datei

{ 
    "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" 
} 

nach npm install @ionic-native/core --save mit ich bin immer Fehler wie this

Antwort

10

ionic-native 3.x Sie @ionic-native/core installieren müssen verwenden.

npm install @ionic-native/[email protected] --save 
+0

ich bekomme Fehler wie konnte nicht installieren –

+0

Ich habe diesen Befehl versucht 'npm installieren @ ionic-native/core --save' wenn ich diesen Befehl verwende ich bekomme Fehler wie' Kann nicht finden Modul "ionic-native" ' –

+0

können Sie die vollständige Fehler msg Frage hinzufügen? –

1

Ich hatte in meinem Paket.json. Für mich war das Problem durch den Import meiner Plugins wie

import {File, Transfer, FilePath} from "ionic-native"; 

statt

import {FilePath} from "@ionic-native/file-path"; 
import {Transfer} from "@ionic-native/transfer"; 
import {File} from "@ionic-native/file"; 
0

gelöst gestern war ich die gleiche Frage, die sich nach meiner ziemlich alten Version auf einen neuen zu aktualisieren. Ich musste viele Schritte durchführen, damit es am Ende funktioniert. Hier ist was ich tun musste, oder wie ich es gelöst habe. Zuerst habe ich ein ‚Dummy‘ Projekt

ionic start myApp tabs 

i die package.json geöffnet und verglichen alle Versionen meiner aktuellen und aktualisiert sie entsprechend (möglicherweise npm outdated verwenden möchten die neuesten und Ihre installierten Versionen zu sehen).

Leider, das nicht für mein Problem lösen, könnte ich mein Projekt bauen, aber ich habe die gleichen Fehler wie Sie cannot find module "ionic-native" nach dem Start.

Nachdem ich viele Posts und Hinweise gelesen hatte, machte ich folgendes (es gab viele andere Fehler, die auftauchten und so löste ich alle).

öffnen app.module.ts und Ihre Importe überprüfen
Bevor:

imports: [ 
    IonicModule.forRoot(MyApp), 
    Ionic2RatingModule 
] 

Nach:

imports: [ 
    BrowserModule, 
    IonicModule.forRoot(MyApp), 
    Ionic2RatingModule, 
    HttpModule /* in case you used http before */ 
] 

Der nächste wichtige Schritt ist, Ihre gesamte Code für
import from "ionic-native"

suchen 10

Falls Sie so etwas finden, müssen Sie es auf die neue Version ändern/aktualisieren. (Dies ist normalerweise für den SplashScreen und die Statusleiste in Ihrer app.component.ts)

Vorher:

import { StatusBar, Splashscreen } from 'ionic-native'; 
@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp { 
    rootPage = HomePage;  
    constructor(platform: Platform) { 
    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. 
     StatusBar.styleDefault(); 
     Splashscreen.hide(); 
    }); 
    platform.pause.subscribe(e=>{ 

    }) 
    } 
} 

Nach:

import {StatusBar} from "@ionic-native/status-bar"; 
import {SplashScreen} from "@ionic-native/splash-screen"; 
    @Component({ 
    templateUrl: 'app.html' 
    }) 
    export class MyApp { 
    rootPage = HomePage; 

    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 
     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. 
     statusBar.styleDefault(); 
     splashScreen.hide(); 
     }); 
     platform.pause.subscribe(e => { 

     }) 
    } 
    } 

den Konstruktor prüfen und die Importe, sie verändert! Ich hatte all diese Änderungen für alles zu tun, die über MODULE import from "ionic-native" wie zum Beispiel importiert wurde: StatusBar, SplashScreen, Camera, Network, Transfer, Geolocation ... auch daran denken, dass jetzt sie an den providers Abschnitt hinzufügen müssen in Ihrem app.module.ts
Falls Sie kein Modul mehr finden (wie es mir für die Kamera passiert ist), stellen Sie sicher, dass Sie das richtige ionische Modul importieren npm install --save @ionic-native/camera
ganz am Ende, Sie sollten keine
MODULE import from "ionic-native"
wieder in Ihrem Code finden. Hoffe, es hilft jemand :)

Verwandte Themen