简体   繁体   English

使用 Angular AOT 构建失败

[英]Build failed with Angular AOT

I am trying to build an Ionic project with ionic cordova build android --prod tag我正在尝试使用ionic cordova build android --prod tag构建一个 Ionic 项目

When I try with dev or normal build, it works.当我尝试使用开发或正常构建时,它可以工作。 But with prod it gives an error.但是使用prod它会出错。

Here is my packages.json file:这是我的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"
    ]
  }
}

Here is my env file:这是我的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

I have no idea what it's doing.我不知道它在做什么。

Got this error:得到这个错误:

[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.

Already tried a few things like commenting a few code lines, but I don't get which file is causing that error.已经尝试了一些诸如注释几行代码之类的方法,但我不知道是哪个文件导致了该错误。 Any help will be appreciated.任何帮助将不胜感激。

I had similar issue try (re)installing @ionic/app-scripts@latest我有类似的问题尝试(重新)安装@ionic/app-scripts@latest

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

sometimes npm sub modules are not correctly saved in node modules.有时 npm 子模块未正确保存在节点模块中。

i'm with this problem too. 我也有这个问题。 Anyone fixed it? 有人修复了吗?

thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM