Angular AOT构建失败

时间:2019-07-29 13:29:34

标签: angular ionic-framework ionic3

我正在尝试使用ionic cordova build android --prod tag

建立一个离子项目

当我尝试开发或正常构建时,它可以工作。但是使用 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.

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

1 个答案:

答案 0 :(得分:0)

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

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

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