Build --prod error: Internal error: unknown identifier []

When I run ionic build --prod I get the following error:

ERROR in Error: Internal error: unknown identifier []
    at Object.importExpr$1 [as importExpr] (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25630:27)
    at /Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20747:37
    at Array.map (<anonymous>)
    at InjectableCompiler.depsArray (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20713:25)
    at InjectableCompiler.factoryFor (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20777:36)
    at InjectableCompiler.injectableDef (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20796:44)
    at InjectableCompiler.compile (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:20806:106)
    at /Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25475:90
    at Array.forEach (<anonymous>)
    at AotCompiler._emitPartialModule2 (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25475:25)
    at /Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25468:48
    at Array.reduce (<anonymous>)
    at AotCompiler.emitAllPartialModules2 (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler/bundles/compiler.umd.js:25467:26)
    at AngularCompilerProgram._emitRender2 (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler-cli/src/transformers/program.js:336:31)
    at AngularCompilerProgram.emit (/Users/me/Documents/Git/myapp/node_modules/@angular/compiler-cli/src/transformers/program.js:211:25)
    at AngularCompilerPlugin._emit (/Users/me/Documents/Git/myapp/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:1040:49)

Ionic Info

    Ionic:

       Ionic CLI                     : 6.9.1 (/Users/me/.nvm/versions/node/v13.12.0/lib/node_modules/@ionic/cli)
       Ionic Framework               : @ionic/angular 5.0.7
       @angular-devkit/build-angular : 0.803.26
       @angular-devkit/schematics    : 8.3.26
       @angular/cli                  : 8.3.26
       @ionic/angular-toolkit        : 2.2.0

    Capacitor:

       Capacitor CLI   : 2.1.0
       @capacitor/core : 2.1.0

    Utility:

       cordova-res : 0.14.0
       native-run  : 1.0.0

    System:

       NodeJS : v13.12.0 (/Users/me/.nvm/versions/node/v13.12.0/bin/node)
       npm    : 6.14.5
       OS     : macOS Catalina

Capacitor Info

Installed Dependencies:

  @capacitor/cli 2.1.0
  @capacitor/android 2.1.0
  @capacitor/ios 2.1.0
  @capacitor/core 2.1.0

[success] Android looking great! 👌
  Found 3 Capacitor plugins for ios:
    cordova-plugin-google-analytics (1.9.0)
    cordova-sqlite-storage (5.0.0)
    es6-promise-plugin (4.2.2)
[success] iOS looking great! 👌

This concerns me. The first thing I would do is to try to get rid of it. If that doesn’t work, audit your code for things mentioned in angular-cli #11359.

1 Like

Thanks for pointing me in the right direction @rapropos.

angular-cli #11359 :point_left:

I was using the @Injectable decorator with a custom class for one of my page components. Removing it fixed the issue.

For anyone who stumbles across this in the future, note that I was getting a Warning: Can't resolve all parameters for that class, but I was ignoring it because I figured I should fix the actual error first. Turns out the warning was pointing me to the root cause of the error, I just didn’t understand it.