SOLVED: Ionic 3.4 --prod Error: Internal Error {"reference": null}


#1

I just upgraded to 3.4 and ionic run ios works fine. But when I run ionic run ios --prod I get this cryptic error:

$ ionic cordova run ios --prod
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[13:23:38]  build prod started ... 
[13:23:38]  clean started ... 
[13:23:38]  clean finished in 2 ms 
[13:23:38]  copy started ... 
[13:23:38]  ngc started ... 
[13:23:42]  copy finished in 4.00 s 
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of
       date.
Error: Internal error: unknown identifier {"reference":null}

I think my install is all up to date:

$ ionic info

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.2.3 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.4.0

System:

    Node       : v7.4.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim    : 5.0.4 
    npm        : 4.0.5 

I’d be grateful for any suggestions!


#2

Uh, that’s a strange one.

  • What does ionic run ios --prod --verbose output?
  • What does npm run ionic:build --prod --verbose output?

#3

Thanks! I didn’t know about --verbose:

$ ionic cordova run ios --prod --verbose
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[14:08:01]  build prod started ... 
[14:08:01]  clean started ... 
[14:08:01]  clean finished in 1 ms 
[14:08:01]  copy started ... 
[14:08:01]  ngc started ... 
[14:08:05]  copy finished in 3.65 s 
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of
       date.
[DEBUG] !!! ERROR ENCOUNTERED !!!
Error: Internal error: unknown identifier {"reference":null}
[DEBUG] Error: Internal error: unknown identifier {"reference":null}
        at _TsEmitterVisitor._resolveStaticSymbol
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19014:19)
        at _TsEmitterVisitor._visitIdentifier
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19032:23)
        at _TsEmitterVisitor.visitExternalExpr
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18694:14)
        at ExternalExpr.visitExpression
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:15906:24)
        at _TsEmitterVisitor.AbstractEmitterVisitor.visitBinaryOperatorExpr
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18385:17)
        at BinaryOperatorExpr.visitExpression
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16047:24)
        at _TsEmitterVisitor.AbstractEmitterVisitor.visitIfStmt
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18072:24)
        at IfStmt.visitStatement
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16456:24)
        at
        /Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18495:58
        at Array.forEach (native)
$ npm run ionic:build --prod --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/7.4.0/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--prod',
npm verb cli   '--verbose' ]
npm info using npm@4.0.5
npm info using node@v7.4.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle agility-course-master@~preionic:build: agility-course-master@
npm info lifecycle agility-course-master@~ionic:build: agility-course-master@

> agility-course-master@ ionic:build /Users/saschwarz/dev/agility-course-master/agility-course-master
> node copy-env-config.js --env prod | ionic-app-scripts build

[14:09:15]  ionic-app-scripts 1.3.7 
[14:09:15]  build prod started ... 
[14:09:15]  clean started ... 
[14:09:15]  clean finished in 1 ms 
[14:09:15]  copy started ... 
[14:09:15]  ngc started ... 
[14:09:19]  copy finished in 4.51 s 
[14:09:22]  ionic-app-script task: "build" 
[14:09:22]  Error: Internal error: unknown identifier {"reference":null} 
Error: Internal error: unknown identifier {"reference":null}
    at _TsEmitterVisitor._resolveStaticSymbol (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19014:19)
    at _TsEmitterVisitor._visitIdentifier (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19032:23)
    at _TsEmitterVisitor.visitExternalExpr (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18694:14)
    at ExternalExpr.visitExpression (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:15906:24)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitBinaryOperatorExpr (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18385:17)
    at BinaryOperatorExpr.visitExpression (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16047:24)
    at _TsEmitterVisitor.AbstractEmitterVisitor.visitIfStmt (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18072:24)
    at IfStmt.visitStatement (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16456:24)
    at /Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18495:58
    at Array.forEach (native)

npm verb lifecycle agility-course-master@~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle agility-course-master@~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/.bin:/usr/local/Cellar/pyenv-virtualenv/1.0.0/shims:/Users/saschwarz/.pyenv/shims:~/Library/Android/sdk/platform-tools:~/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
npm verb lifecycle agility-course-master@~ionic:build: CWD: /Users/saschwarz/dev/agility-course-master/agility-course-master
npm info lifecycle agility-course-master@~ionic:build: Failed to exec ionic:build script
npm verb stack Error: agility-course-master@ ionic:build: `node copy-env-config.js --env prod | ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at EventEmitter.emit (events.js:191:7)
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at ChildProcess.emit (events.js:191:7)
npm verb stack     at maybeClose (internal/child_process.js:885:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid agility-course-master@
npm verb cwd /Users/saschwarz/dev/agility-course-master/agility-course-master
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "run" "ionic:build" "--prod" "--verbose"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! agility-course-master@ ionic:build: `node copy-env-config.js --env prod | ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the agility-course-master@ ionic:build script 'node copy-env-config.js --env prod | ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the agility-course-master package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node copy-env-config.js --env prod | ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs agility-course-master
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls agility-course-master
npm ERR! There is likely additional logging output above.
npm verb exit [ 1, true ]

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/saschwarz/dev/agility-course-master/agility-course-master/npm-debug.log

#4

Unfortunately doesn’t tell me much :confused:

The compiler doesn’t like something. Unfortunately it doesn’t really tell us what it is.


#5

I ran npm install -g @ionic/cli-plugin-proxy and now it finds that plugin:

$ ionic cordova run ios --prod --verbose
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[14:16:24]  build prod started ... 
[14:16:24]  clean started ... 
[14:16:24]  clean finished in 2 ms 
[14:16:24]  copy started ... 
[14:16:24]  ngc started ... 
[14:16:28]  copy finished in 3.78 s 
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of
       date.
[DEBUG] !!! ERROR ENCOUNTERED !!!
Error: Internal error: unknown identifier {"reference":null}
[DEBUG] Error: Internal error: unknown identifier {"reference":null}
        at _TsEmitterVisitor._resolveStaticSymbol
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19014:19)
        at _TsEmitterVisitor._visitIdentifier
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:19032:23)
        at _TsEmitterVisitor.visitExternalExpr
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18694:14)
        at ExternalExpr.visitExpression
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:15906:24)
        at _TsEmitterVisitor.AbstractEmitterVisitor.visitBinaryOperatorExpr
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18385:17)
        at BinaryOperatorExpr.visitExpression
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16047:24)
        at _TsEmitterVisitor.AbstractEmitterVisitor.visitIfStmt
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18072:24)
        at IfStmt.visitStatement
        (/Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:16456:24)
        at
        /Users/saschwarz/dev/agility-course-master/agility-course-master/node_modules/@angular/compiler/bundles/compiler.umd.js:18495:58
        at Array.forEach (native)

#6

If it’s complaining about “static symbols” is that possibly due to the changes in how AOT expects providers to be specified?


#7

I’m putting debugging code in the compiler and walking up the stack to see if I can find the symbol.


#8

Not neccessary if you don’t use a proxy - the debug message is just voiced a bit “harsh”.

Good luck with the debugging.
Maybe also open an issue with Ionic on Github so the devs are aware.


#9

I would be interested in seeing package.json here. I suspect a problem (perhaps in a library) involving DI declarations using tokens.


#10

Just found the problem:

import * as Rollbar from 'rollbar';
...
const providers = [
    ...
        {
            provide: Rollbar,
            useFactory: rollbarFactory
        },
    ...
}

Removing the Rollbar object from the providers solved it. I just need to dig into the reason it worked in early versions of Angular.


#11

I would take a look at angular-rollbar.


#12

For Angular 4 and the latest rollbar 2.0 package installed via: npm install rollbar --save the solution is to change the import to:

let Rollbar = require('rollbar');

#13

I had the exact same error but on my case the culprit was

import ApolloClient from 'apollo-client';

as seen on GitHunt-Angular

changing it to:

import { ApolloClient } from 'apollo-client';

solved my two days quest.


#14

I needed to solve this error with Rollbar by using InjectionToken instead, here’s where I found the answer. https://github.com/rollbar/rollbar.js/issues/446