Cant build with --prod

Hello there,

All of the sudden, I cant build anymore with:

ionic cordova build android --prod --release

The error I get is:

typescript error
            Cannot determine the module for class OverlayPortal in
            D:/Projects/ionic/leiderschapp/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
            D:/Projects/ionic/leiderschapp/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
            D:/Projects/ionic/leiderschapp/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 D:\Projects\ionic\leiderschapp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
    at step (D:\Projects\ionic\leiderschapp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (D:\Projects\ionic\leiderschapp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
    at fulfilled (D:\Projects\ionic\leiderschapp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
    at <anonymous>

I have tried almost every SO and forum topic Google offered me, but without results :

Cannot determine the module for class IonicApp command: ionic cordova build <platform> --prod --release failure
angular - Error: Cannot determine the module for class OverlayPortal in --prod - Stack Overflow

ionic info:

cli packages: (C:\Users\duncan\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.10
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.10.0
    npm  : 6.1.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

Edit #1:

I found out that the problem is in --prod. I can build perfectly fine with just --release.

1 Like

I would guess that your imports are wrong, and that you are trying to import the individual overlay-portal.d.ts, app-root.d.ts and click-block.d.ts, but no way for me to know that of course other than what the error message says.

It’s also possible you have some config issue, but I’d check the imports first.

Thanks for your reply. I have searched the complete project for any of the 3 and it only came up with results in the node_modules/ionic-angular/ folder.

I have checked most of my imports, but I am not sure what I am looking for. I dont import any .d.ts files.

I checked out an earlier git commit, where I could build the APK. There it gives the same error now.

Ya just make sure you don’t have any imports that contain ionic-angular/components/app/

You may need to wipe out your node modules and re-install? You can just delete the folder than do a new npm install. If you’re sure you used --prod when building the previous commit you checked out, then this is almost certainly the issue, since node_modules won’t be affected by git.

I have found some imports to ionic-angular/components/app/.
But they all seem to be generated automatic:

platforms/android/assets/www/build/vendor.js.map
platforms/android/build/intermediates/assets/debug/www/build/vendor.js.map
platforms/android/build/intermediates/assets/release/www/build/vendor.js.map
platforms/ios/www/build/vendor.js.map
www/build/vendor.js.map

I removed my node_modules and the android platform.
Re-installed with NPM and re-added the platform. Had some other trouble with android 7.*.
When I downgraded, I was back at this error.

I have the same problem, replacing any ionic-angular/ for ionic-angular solved the problem

2 Likes

Today I updated the ionic native apps that I use to 4.9.0 and that has solved the problem.
My guess is that the problem was in 1 of them.

1 Like

Worked for me, thanks.

1 Like