ionic build android --prod --release中的AOT错误

时间:2018-07-15 03:03:17

标签: angular typescript ionic3

我有一个离子项目。
ionic serveionic build android中没有问题。
但在版本apk中使用--prod,则抛出异常:

Running app-scripts build: --prod --platform android --target cordova
[07:21:15]  build prod started ... 
[07:21:15]  clean started ... 
[07:21:15]  clean finished in 1 ms 
[07:21:15]  copy started ... 
[07:21:15]  deeplinks started ... 
[07:21:15]  deeplinks finished in 265 ms 
[07:21:15]  ngc started ... 
[07:21:24]  typescript error 
        Cannot determine the module for class OverlayPortal in 
        /home/rashidi/workspace/discountNetMobile/node_modules/ionic-angular/components/app/overlay-portal.d.ts! Add 
        OverlayPortal to the NgModule to fix it. Cannot determine the module for class IonicApp in 
        /home/rashidi/workspace/discountNetMobile/node_modules/ionic-angular/components/app/app-root.d.ts! Add 
        IonicApp to the NgModule to fix it. Cannot determine the module for class ClickBlock in 
        /home/rashidi/workspace/discountNetMobile/node_modules/ionic-angular/components/app/click-block.d.ts! Add 
        ClickBlock to the NgModule to fix it. 

Error: The Angular AoT build failed. See the issues above
at /home/rashidi/workspace/discountNetMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
at step (/home/rashidi/workspace/discountNetMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/home/rashidi/workspace/discountNetMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at fulfilled (/home/rashidi/workspace/discountNetMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
at <anonymous>

package.json如下:

"dependencies": {
    "@angular/animations": "5.2.11",
    "@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",
    "@angular/router": "5.2.11",
    "@ionic-native/contacts": "4.9.2",
    "@ionic-native/core": "4.9.2",
    "@ionic-native/deeplinks": "^4.9.2",
    "@ionic-native/device": "4.9.2",
    "@ionic-native/diagnostic": "^4.9.2",
    "@ionic-native/file": "^4.9.2",
    "@ionic-native/file-opener": "^4.9.2",
    "@ionic-native/file-transfer": "^4.9.2",
    "@ionic-native/geolocation": "^4.9.2",
    "@ionic-native/in-app-browser": "4.9.2",
    "@ionic-native/network": "4.9.2",
    "@ionic-native/push": "^4.9.2",
    "@ionic-native/sim": "4.9.2",
    "@ionic-native/social-sharing": "4.9.2",
    "@ionic-native/splash-screen": "4.9.2",
    "@ionic-native/status-bar": "^4.9.2",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "9.1.1",
    "@ngx-translate/http-loader": "2.0.1",
    "@types/leaflet": "1.2.8",
    "com.lampa.startapp": "^6.1.6",
    "cordova-android": "7.1.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-contacts": "^3.0.1",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-file-opener2": "^2.0.19",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-inappbrowser": "^3.0.0",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-sim": "^1.3.3",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "^5.4.1",
    "cordova-support-google-services": "^1.2.0",
    "cordova-universal-links-plugin": "^1.2.1",
    "cordova.plugins.diagnostic": "^4.0.8",
    "es6-promise-plugin": "^4.2.2",
    "intersection-observer": "0.5.0",
    "ionic": "^3.20.0",
    "ionic-angular": "3.9.2",
    "ionic-img-viewer": "2.9.0",
    "ionic-plugin-deeplinks": "^1.0.17",
    "ionic-plugin-deploy": "^0.6.7",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic-stepper": "^1.1.0",
    "ionic2-rating": "^1.2.2",
    "ionicons": "4.2.4",
    "jalali-moment": "3.1.2",
    "leaflet": "1.3.1",
    "leaflet.label": "0.2.4",
    "libphonenumber-js": "1.2.21",
    "moment": "2.22.2",
    "ng-in-viewport": "1.2.8",
    "ng2-validation": "4.2.0",
    "phonegap-plugin-multidex": "^1.0.0",
    "phonegap-plugin-push": "^2.2.3",
    "promise-polyfill": "8.0.0",
    "rxjs": "5.5.10",
    "sw-toolbox": "3.6.0",
    "underscore": "1.9.1",
    "zone.js": "0.8.26"
},
"devDependencies": {
    "@ionic/app-scripts": "^3.1.11",
    "typescript": "2.9.2"
}

我不明白问题是什么。
如何诊断问题出在哪里?

2 个答案:

答案 0 :(得分:0)

我解决了将Angular版本5.2.11更改为5.2.8的问题

答案 1 :(得分:-2)

看看错误告诉您问题可能是什么:

Add IonicApp to the NgModule to fix it. 
Cannot determine the module for class ClickBlock in...

您是否已将IonicApp添加到模块中?