Angular 离子3型'型;任何';不是构造函数类型
在我的linux任务中,我有我的ionic 2项目,当时我正在处理并转移到有ionic 3的mac上 因此,我创建了一个新项目,并用新项目替换了页面、提供、组件文件夹,我遇到了错误,如Angular 离子3型'型;任何';不是构造函数类型,angular,ionic2,native,node-modules,ionic3,Angular,Ionic2,Native,Node Modules,Ionic3,在我的linux任务中,我有我的ionic 2项目,当时我正在处理并转移到有ionic 3的mac上 因此,我创建了一个新项目,并用新项目替换了页面、提供、组件文件夹,我遇到了错误,如找不到模块“ionic native”将插件导入app.modulete.ts文件后,我遇到了错误,因为“Type”any不是构造函数函数类型` 我的终端显示 17:39:48] typescript: node_modules/@ionic-native/app-version/index.d.ts, line
找不到模块“ionic native”
将插件导入app.modulete.ts文件后,我遇到了错误,因为“Type”any不是构造函数函数类型`
我的终端显示
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/
在我的浏览器中,我遇到了如下错误
这是我的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
后,我遇到了类似的错误,要使用ionic native
3.x,您需要安装@ionic native/core
npm install @ionic-native/core@3.6.1 --save
我的package.json中有
@ionic native/core^3.6.0
。对我来说,通过导入我的插件解决了这个问题,比如
import {File, Transfer, FilePath} from "ionic-native";
而不是
import {FilePath} from "@ionic-native/file-path";
import {Transfer} from "@ionic-native/transfer";
import {File} from "@ionic-native/file";
昨天,在将我的旧版本更新为新版本后,我遇到了同样的问题。 我必须执行很多步骤才能使它最终发挥作用。以下是我需要做的,或者我是如何解决的。 首先,我创建了一个“虚拟”项目
ionic start myApp tabs
我打开了package.json
并将所有版本与我当前的版本进行了比较,并相应地进行了更新(您可能希望使用npm-oplated
查看最新版本和已安装的版本)
不幸的是,这并没有解决我的问题,我可以构建我的项目,但我遇到了与您相同的错误无法找到模块“ionic native”
开始之后
在阅读了大量帖子和提示后,我做了以下工作(还有很多其他错误,我就是这样解决的)
打开app.module.ts
并检查您的导入之前: 之后: 下一个重要步骤是在整个代码中搜索
从“ionic native”导入
如果您发现类似的内容,您必须将其更改/更新为新版本。(通常用于app.component.ts中的splashScreen和状态栏)
之前:
之后:
检查构造函数和导入,它们已更改!
我必须对通过模块导入从“ionic native”导入的所有内容进行所有这些更改,例如:状态栏、SplashScreen、摄像头、网络、传输、地理位置…
还要记住,现在您必须将它们添加到app.module.ts
如果您再也找不到模块(就像我在相机上遇到的情况),请确保导入正确的ionic模块npm安装--save@ionic native/Camera
最后,您不应该找到任何
从“离子本机”导入模块
同样,在代码中。
希望它能帮助某些人:)我已经尝试过这个命令npm install@ionic native/core--save
如果我使用这个命令,我会遇到类似找不到模块“ionic native”的错误
ionic terminal没有向我显示任何错误请看我更新问题的图像ionic native..cordova插件与serve不兼容。请使用设备/模拟器,但我没有使用任何插件我已对代码中使用的所有插件进行了注释您在哪里使用“cordova插件应用程序版本”?
imports: [
IonicModule.forRoot(MyApp),
Ionic2RatingModule
]
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
Ionic2RatingModule,
HttpModule /* in case you used http before */
]
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=>{
})
}
}
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 => {
})
}
}