Error with --prod


#1

Hello,

When i use ionic cordova build android --prod --release it gives a strange error. I tried to fix it but it always results in a broken app. Does anyone have an ideahow to solve this?
Ionic cordova build android --realease works perfect btw.

Thanks in advance!

Greetings,
Nyffellare

Here is the error:

PS D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers> ionic cordova build android --prod --release
[INFO] Running app-scripts build: --prod --platform android --target cordova

[15:35:02]  build prod started ...
[15:35:02]  clean started ...
[15:35:02]  clean finished in 1 ms
[15:35:02]  copy started ...
[15:35:02]  ngc started ...
Error: Type AboutPage in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.ts is part of the declarations of 2 modules: AppModule in D:/Personal_Files/Documenten/Ion
ic/ChecklistByBlackSuitDevelopers/src/app/app.module.ts and AboutPageModule in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.module.ts! Please consider moving Ab
outPage in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.ts to a higher module that imports AppModule in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitD
evelopers/src/app/app.module.ts and AboutPageModule in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.module.ts. You can also create a new NgModule that exports a
nd includes AboutPage in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.ts then import that NgModule in AppModule in D:/Personal_Files/Documenten/Ionic/ChecklistB
yBlackSuitDevelopers/src/app/app.module.ts and AboutPageModule in D:/Personal_Files/Documenten/Ionic/ChecklistByBlackSuitDevelopers/src/pages/about/about.module.ts.
    at Error (native)
    at syntaxError (D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:1550:34)
    at CompileMetadataResolver._addTypeToModule (D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:14655:31)
    at D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:14543:27
    at Array.forEach (native)
    at CompileMetadataResolver.getNgModuleMetadata (D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:14534:54)
    at addNgModule (D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:23050:58)
    at D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:23061:14
    at Array.forEach (native)
    at _createNgModules (D:\Personal_Files\Documenten\Ionic\ChecklistByBlackSuitDevelopers\node_modules\@angular\compiler\bundles\compiler.umd.js:23060:26)

#2

Not strange at all I think

  Type AboutPage in ... is part of the declarations of 2 modules...
  app.module.ts
 about.module.ts

You are using lazy loading? Delete the entry in app.module.ts about AboutPageModule
You are not using lazy loading? Delete about.module.ts

P.S.: Using --prod option when building in comparison to “just” running ionic server will perform extra checks