【问题标题】:Build failed with Angular AOT使用 Angular AOT 构建失败
【发布时间】:2019-11-11 20:16:11
【问题描述】:

我正在尝试使用 ionic cordova build android --prod tag 构建一个 Ionic 项目

当我尝试使用开发或正常构建时,它可以工作。但是使用 prod 会报错。

这是我的 packages.json 文件:

{
  "name": "chimera",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "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/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/admob-free": "4.20.0",
    "@ionic-native/call-number": "4.16.0",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/email-composer": "4.16.0",
    "@ionic-native/file-opener": "^4.16.0",
    "@ionic-native/in-app-browser": "4.20.0",
    "@ionic-native/onesignal": "^4.20.0",
    "@ionic-native/social-sharing": "4.16.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/cloud-angular": "0.12.0",
    "@ionic/pro": "1.0.16",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "9.1.1",
    "@ngx-translate/http-loader": "3.0.1",
    "angular2-masonry": "0.4.0",
    "call-number": "1.0.1",
    "cordova-admob-sdk": "^0.13.1",
    "cordova-android": "6.4.0",
    "cordova-ios": "4.5.5",
    "cordova-plugin-admob-free": "^0.13.0",
    "cordova-plugin-compat": "1.2.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-file-opener2": "^2.2.1",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-whitelist": "^1.3.4",
    "cordova-plugin-x-socialsharing": "^5.4.7",
    "cordova-promise-polyfill": "0.0.2",
    "es6-promise-plugin": "^4.2.2",
    "ionic-angular": "3.9.2",
    "ionic-marquee": "0.4.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "mx.ferreyra.callnumber": "0.0.2",
    "ng2-twitter": "0.3.0",
    "onesignal-cordova-plugin": "^2.5.0",
    "rxjs": "6.3.3",
    "rxjs-compat": "6.3.3",
    "sw-toolbox": "3.6.0",
    "webpack-sources": "1.3.0",
    "xml2js": "0.4.19",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.4",
    "@ionic/lab": "1.0.2",
    "@types/xml2js": "0.4.3",
    "typescript": "2.4.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+",
        "PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to function properly."
      },
      "mx.ferreyra.callnumber": {},
      "cordova-plugin-admob-free": {
        "ADMOB_APP_ID": "ca-app-pub-2899054860592317~3367233553"
      },
      "cordova-plugin-device": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "call-number": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "onesignal-cordova-plugin": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }
}

这是我的 env 文件:

Ionic:

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

Cordova:

   Cordova CLI       : 8.0.0
   Cordova Platforms : android 6.4.0
   Cordova Plugins   : cordova-plugin-ionic-webview 1.2.1, (and 9 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.8

System:

   ios-deploy : 1.9.4
   NodeJS     : v8.12.0 (/usr/local/bin/node)
   npm        : 6.4.1
   OS         : macOS Mojave
   Xcode      : Xcode 10.3 Build version 10G8

我不知道它在做什么。

得到这个错误:

[14:19:12]  typescript error 
            Error during template compile of 'BrowserXhr' Function calls are not supported in decorators but 
            'makeDecorator' was called in 'Injectable' 'Injectable' references 'Injectable' 'Injectable' references 
            'Injectable' 'Injectable' references 'Injectable' 'Injectable' calls 'makeDecorator'. 

[14:19:12]  ionic-app-script task: "build" 
[14:19:12]  Error: The Angular AoT build failed. See the issues above 
Error: The Angular AoT build failed. See the issues above
    at /Users/wasiq/Desktop/development/fantaproapp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
    at step (/Users/wasiq/Desktop/development/fantaproapp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/Users/wasiq/Desktop/development/fantaproapp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/Users/wasiq/Desktop/development/fantaproapp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
    at <anonymous>
[ERROR] An error occurred while running subprocess ionic-app-scripts.

已经尝试了一些方法,例如注释几行代码,但我不知道是哪个文件导致了该错误。任何帮助将不胜感激。

【问题讨论】:

  • 我认为这与 forRoot() 您的模块导入有关。尝试添加“.forRoot() 显示:@NgModule({ imports: [ YourModule.forRoot(), ], ... }
  • @RobinWebb 我都试过了,抱歉没用。只是让我从过去 6 小时的笔记工作中抓狂

标签: angular ionic-framework ionic3


【解决方案1】:

我有类似的问题 尝试(重新)安装@ionic/app-scripts@latest

npm --save install @ionic/app-scripts@latest

有时 npm 子模块未正确保存在节点模块中。

【讨论】:

  • 已经尝试将其从节点模块中删除并重新安装或再次更新但同样的错误
  • 尝试删除整个节点模块并重新安装所有内容。这也可能是由于 package.json 中的 npm 包版本之间的不匹配造成的。您收到的这些警告对我来说似乎有点奇怪,请查看具有兼容版本的 package.json。
  • 它不工作你能建议别的吗
  • github.com/ionic-team/ionic-app-scripts/issues/1516 这可能是相关的,也请尝试更新您的包 json 中的版本,它们似乎不兼容。这是我的 package.json 缺少您的一些依赖项,但我没有收到您的错误。 pastebin.com/k60kXtTD。希望这会有所帮助
  • 谢谢让我查一下
猜你喜欢
  • 2020-12-02
  • 2017-10-22
  • 2017-03-10
  • 1970-01-01
  • 1970-01-01
  • 2020-09-03
  • 2018-05-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多