ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
609 stars 300 forks source link

TypeError: Cannot read property 'ngModuleByPipeOrDirective' of undefined #1500

Open sinanzt opened 5 years ago

sinanzt commented 5 years ago

Description:

when I run build code ( ionic cordova build android --prod --release ) I giving this:

[05:50:02] ionic-app-scripts 3.2.1 [05:50:02] build prod started ... [05:50:02] clean started ... [05:50:02] clean finished in 2 ms [05:50:02] copy started ... [05:50:02] deeplinks started ... [05:50:02] deeplinks finished in 54 ms [05:50:02] ngc started ... [05:50:06] ionic-app-script task: "build" [05:50:06] TypeError: Cannot read property 'ngModuleByPipeOrDirective' of undefined TypeError: Cannot read property 'ngModuleByPipeOrDirective' of undefined at AotCompiler.emitAllImpls (/Users/aaa/Project/CCA/node_modules/@angular/compiler/bundles/compiler.umd.js:30807:55) at AngularCompilerProgram.generateFilesForEmit (/Users/aaa/Project/CCA/node_modules/@angular/compiler-cli/src/transformers/program.js:736:46) at AngularCompilerProgram._emitRender2 (/Users/aaa/Project/CCA/node_modules/@angular/compiler-cli/src/transformers/program.js:330:27) at AngularCompilerProgram.emit (/Users/aaa/Project/CCA/node_modules/@angular/compiler-cli/src/transformers/program.js:236:22) at /Users/aaa/Project/CCA/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:223:38 at step (/Users/aaa/Project/CCA/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23) at Object.next (/Users/aaa/Project/CCA/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53) at fulfilled (/Users/aaa/Project/CCA/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58) [ERROR] An error occurred while running subprocess ionic-app-scripts.

    ionic-app-scripts build --prod --target cordova --platform android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

My ionic info:

Ionic:

ionic (Ionic CLI) : 4.5.0 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova Platforms : android 7.1.4 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 5 other plugins)

System:

NodeJS : v10.13.0 (/usr/local/bin/node) npm : 6.4.1 OS : macOS Mojave

gabrfer commented 5 years ago

Hello,

I was suffering the same problem. In my case it was because an incompatibility between my angular version and my "angular-cli" version wich I updated without be careful of this.

"@angular/common": "5.2.9", "@angular/compiler": "5.2.9", "@angular/compiler-cli": "^7.1.4", "@angular/core": "5.2.9",

I'm working in Angular5, so, with "@angular/compiler-cli" in "5.2.9" version I solved the problem.

Kind regards. Fernando.

hvallenilla commented 5 years ago

Hello,

I was suffering the same problem. In my case it was because an incompatibility between my angular version and my "angular-cli" version wich I updated without be careful of this.

"@angular/common": "5.2.9", "@angular/compiler": "5.2.9", "@angular/compiler-cli": "^7.1.4", "@angular/core": "5.2.9",

I'm working in Angular5, so, with "@angular/compiler-cli" in "5.2.9" version I solved the problem.

Kind regards. Fernando.

Thanks so much

zulfiqarnasha commented 5 years ago

Hello,

I was suffering the same problem. In my case it was because an incompatibility between my angular version and my "angular-cli" version wich I updated without be careful of this.

"@angular/common": "5.2.9", "@angular/compiler": "5.2.9", "@angular/compiler-cli": "^7.1.4", "@angular/core": "5.2.9",

I'm working in Angular5, so, with "@angular/compiler-cli" in "5.2.9" version I solved the problem.

Kind regards. Fernando.

Hi, how do you change the @angular/compiler-cli version? This is my ng version

"@angular/cli": "^7.3.5", "@angular/common": "5.0.3", "@angular/compiler": "5.0.3", "@angular/compiler-cli": "^7.2.6", "@angular/core": "5.0.3"

Angular CLI: 7.3.5 Node: 11.10.0 OS: win32 x64 Angular: 5.0.3 ... common, compiler, core, forms, http, platform-browser ... platform-browser-dynamic Package Version


@angular-devkit/architect 0.13.5
@angular-devkit/build-optimizer 0.0.35
@angular-devkit/core 7.3.5
@angular-devkit/schematics 7.3.5
@angular/animations 4.4.6
@angular/cli 7.3.5
@angular/compiler-cli 7.2.6
@angular/tsc-wrapped 0.5.2
@ngtools/webpack 1.10.2
@schematics/angular 7.3.5
@schematics/update 0.13.5
rxjs 5.5.2
typescript 3.1.6
webpack 3.12.0

gabrfer commented 5 years ago

Hi zulfiqarnasha,

I changed "@angular/compiler-cli " version in my "package.json", writing the same version as "@angular/core" and the others.

And then, I ran an "npm update" to get the updated version.

Maybe you'll have to do the same with "@angular/cli".

I hope you can solve the problem.

King regards. Fernando.

zulfiqarnasha commented 5 years ago

Thank you for the response, and I've tried everything you mentioned but it still doesn't work. So I tried following this (ionic-v1)

$ ionic cordova build --release android

to build the apk instead of this (ionic-v3)

ionic cordova build android --prod --release

and it solved the issue.