【问题标题】:Ionic 4 with angular 7, Cannot find type definition file for '@types'带有角度 7 的 Ionic 4,找不到“@types”的类型定义文件
【发布时间】:2019-10-11 13:16:13
【问题描述】:

我升级了我的 ionic 4 项目以使用 angular 7,一切都在调试模式下工作,但是当我尝试编译生产时: 'ionic cordova build android --prod',我得到以下输出:

ionic-app-scripts build --prod --target cordova --platform android [20:24:15] 离子应用脚本 3.2.4 ... [20:24:44] 打字稿错误 找不到“@types”的类型定义文件。

[20:24:44] 离子应用脚本任务:“构建” [20:24:44] 错误:无法转换 TypeScript 错误:无法转换 TypeScript 在errorCheckProgram(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:119:39) 在对象。 (/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:89:21) 在步骤(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23) 在 Object.next (/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53) 完成时(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58) [ERROR] 运行子进程 ionic-app-scripts 时出错。

ionic-app-scripts build --prod --target cordova --platform android 以退出代码 1 退出。

我还没有找到任何解决这个问题的方法,所以如果有人可以让我找到正确的方向来解决这个问题,我真的很感激。 我的 package.json 是:

{
  "name": "xxxxxxx",
  "version": "1.0.2",
  "author": "xxxxxx",
  "homepage": "xxxxx",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/animations": "7.2.15",
    "@angular/cli": "^7.3.9",
    "@angular/common": "7.2.15",
    "@angular/compiler": "7.2.15",
    "@angular/compiler-cli": "7.2.15",
    "@angular/core": "7.2.15",
    "@angular/forms": "7.2.15",
    "@angular/http": "7.2.15",
    "@angular/platform-browser": "7.2.15",
    "@angular/platform-browser-dynamic": "7.2.15",
    "@ionic-native/android-full-screen": "^5.6.0",
    "@ionic-native/core": "^5.6.0",
    "@ionic-native/mobile-accessibility": "^5.6.0",
    "@ionic-native/splash-screen": "^5.6.0",
    "@ionic-native/status-bar": "^5.6.0",
    "@ionic/pro": "1.0.20",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "^9.1.1",
    "@ngx-translate/http-loader": "^2.0.1",
    "cordova-android": "~7.0.0",
    "cordova-ios": "4.5.5",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-fullscreen": "^1.2.0",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^2.3.1",
    "cordova-plugin-network-information": "git+https://github.com/apache/cordova-plugin-network-information.git",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "ionic-angular": "^3.9.6",
    "ionicons": "3.0.0",
    "phonegap-plugin-mobile-accessibility": "^1.0.5",
    "rxjs": "6.5.2",
    "rxjs-compat": "^6.0.0-rc.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.29"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.4",
    "@types/node": "^12.0.2",
    "typescript": "^3.2.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-fullscreen": {},
      "phonegap-plugin-mobile-accessibility": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-statusbar": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }
}

离子信息:

Ionic:

   ionic (Ionic CLI)  : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.6
   @ionic/app-scripts : 3.2.4

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 2.3.1, (and 7 other plugins)

System:

   NodeJS : v10.11.0 (/usr/local/Cellar/node/10.11.0/bin/node)
   npm    : 6.9.0
   OS     : macOS Mojave
   Xcode  : Xcode 10.2.1 Build version 10E1001

【问题讨论】:

    标签: angular typescript ionic-framework angular-aot


    【解决方案1】:

    根据您分享的数据,您的项目是 Ionic 3 项目 (3.9.6)。

    Ionic 3 不适合与 Angular 6+ 一起使用。

    我建议检查 Ionic 3 参考应用程序的 package.json 并相应地降级您的依赖项。

    Reference App v3 branch

    【讨论】:

      【解决方案2】:

      ionic-app-script 最近更新产生了这个错误。

      作为一种解决方法,您可以将 package.json 中的版本锁定为最后一个工作版本:

      "@ionic/app-scripts": "3.2.3"

      或降级

      【讨论】:

      • 好吧,不是最近,而是给那些使用 ionic 3 编码的人
      【解决方案3】:

      解决方案:使用ionic serve 为您的项目提供服务,然后更新 src 文件夹中的任何 .ts 文件并保存(ctrl+s),它将自动重新构建并提供应用程序,错误将得到解决,希望 :)。

      这解决了我的问题。

      引用自 ionic 框架论坛上发布的说明。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-03-09
        • 2019-05-15
        • 2019-03-11
        • 2018-06-05
        • 2018-06-09
        • 2017-12-04
        • 1970-01-01
        • 2019-01-12
        相关资源
        最近更新 更多