Error "Cannot determine the module for class OverlayPortal" with --prod build

I got this error when I try to build with --prod for android

[16:51:11]  typescript error 
            Cannot determine the module for class OverlayPortal in 
            /root/ionic/KiaApp/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 
            /root/ionic/KiaApp/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 
            /root/ionic/KiaApp/node_modules/ionic-angular/components/app/click-block.d.ts! Add ClickBlock to the 
            NgModule to fix it. 

[16:51:11]  ionic-app-script task: "build" 
[16:51:11]  Error: The Angular AoT build failed. See the issues above 
Error: The Angular AoT build failed. See the issues above
    at /root/ionic/KiaApp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
    at step (/root/ionic/KiaApp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/root/ionic/KiaApp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/root/ionic/KiaApp/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
[ERROR] An error occurred while running subprocess ionic-app-scripts.

I have this ionic-info

Ionic:

   ionic (Ionic CLI)  : 4.5.0 (/Users/adanluna/.npm-global/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.2
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 14 other plugins)

System:

   NodeJS : v11.1.0 (/usr/local/Cellar/node/11.1.0/bin/node)
   npm    : 6.4.1
   OS     : macOS Mojave
   Xcode  : Xcode 10.1 Build version 10B61

I’m in shock with this error, I reading many posts with solutions but no one works for me .

Hello
I am facing the same problem. Have you ever found a solution?

No, but I think that some plugin is giving this error

I finally found the solution. You can follow this link https://stackoverflow.com/questions/46599017/error-cannot-determine-the-module-for-class-overlayportal-in-prod/50858210 where you will learn about LOADINCONTROLLER IMPORT.

I verify my code and apply this for all my component who don’t respect the rules.

1 Like