Error on build --prod

Hello, when using the command

ionic capacitor build android

works correctly for me. The problem happens when I use the command with the --prod flag

ionic capacitor build android --prod

I throw this error:

āœ” Browser application bundle generation complete.
Error: ./src/main.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (/home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:261:56)
    at /home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:374:20
    at analyzingFileEmitter (/home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
 @ multi ./src/main.ts main[0]

Error: ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (/home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:261:56)
    at /home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:374:20
    at analyzingFileEmitter (/home/kevin/proyectos/photo-gallery/node_modules/@ngtools/webpack/src/ivy/plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
 @ multi ./node_modules/@angular-devkit/build-angular/src/webpack/es5-polyfills.js zone.js/dist/zone-legacy ./src/polyfills.ts polyfills-es5[2]

Anybody trying to help would probably want to see your package.json and the output of ionic info.

1 Like

My package.json

{
  "name": "photo-gallery",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~10.0.0",
    "@angular/core": "~10.0.0",
    "@angular/forms": "~10.0.0",
    "@angular/platform-browser": "~10.0.0",
    "@angular/platform-browser-dynamic": "~10.0.0",
    "@angular/router": "~10.0.0",
    "@capacitor/android": "^2.4.6",
    "@capacitor/core": "2.4.6",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/pwa-elements": "^3.0.2",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1101.1",
    "@angular/cli": "~10.0.5",
    "@angular/compiler": "~10.0.0",
    "@angular/compiler-cli": "~10.0.0",
    "@angular/language-service": "~10.0.0",
    "@capacitor/cli": "2.4.6",
    "@ionic/angular-toolkit": "^2.3.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
  "description": "An Ionic project"
}

ionic info results:

Ionic:

   Ionic CLI                     : 6.12.4 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.5.2
   @angular-devkit/build-angular : 0.1101.1
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res : 0.15.2
   native-run  : 1.3.0

System:

   NodeJS : v10.19.0 (/usr/bin/node)
   npm    : 6.14.11
   OS     : Linux 5.8

This looks out of sync with everything else. I would suggest bringing it back down to 0.10xx or updating the rest of the Angular stuff to 11.x.

All Possible Solution added at Here Just Visit TypeError: angularCompiler.getResourceDependencies(ā€¦) is not a function or its return value is not iterable

I have solved that by doing:

ng update @angular/core @angular/cli
ng update

Hope it helps.