Can't build --prod release for any platforms


#1
$ 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.12
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.2.3 browser 4.1.0
    Ionic Framework                 : ionic-angular 3.5.0

System:

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


$ ionic cordova build android --prod
Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser

[21:44:46]  build prod started ...
[21:44:46]  clean started ...
[21:44:46]  clean finished in 1 ms
[21:44:46]  copy started ...
[21:44:46]  ngc started ...
[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 [{"filePath":"/Users/os/projects/os-slides/node_modules/@angular/core/core.d.ts","name":"ErrorHandler","members":[]}]

package.json

    "dependencies": {
        "@angular/common": "^4.1.3",
        "@angular/compiler": "^4.1.3",
        "@angular/compiler-cli": "^4.1.3",
        "@angular/core": "^4.1.3",
        "@angular/forms": "^4.1.3",
        "@angular/http": "^4.1.3",
        "@angular/platform-browser": "^4.1.3",
        "@angular/platform-browser-dynamic": "^4.1.3",
        "@ionic-native/core": "^3.12.1",
        "@ionic-native/splash-screen": "^3.12.1",
        "@ionic-native/status-bar": "^3.12.1",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-browser": "^4.1.0",
        "cordova-plugin-console": "^1.0.7",
        "cordova-plugin-device": "^1.1.6",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.3",
        "cordova-plugin-whitelist": "^1.3.2",
        "ionic-angular": "3.5.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "ng2-responsive": "^0.8.4",
        "promise-polyfill": "6.0.2",
        "rxjs": "^5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "1.3.12",
        "@ionic/cli-plugin-cordova": "^1.4.0",
        "@ionic/cli-plugin-ionic-angular": "1.3.1",
        "typescript": "2.3.4"
    },

Can’t figure out what’s going on.

Builds go fine without --prod.


#2
  1. Run ionic cordova build android --prod --verbose please.
  2. Run npm run ionic:build --verbose please.

#3

Here’s the output:

$ ionic cordova build android --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 --iscordovaserve --externalIpRequired --nobrowser

[22:00:10]  build prod started ...
[22:00:10]  clean started ...
[22:00:10]  clean finished in 1 ms
[22:00:10]  copy started ...
[22:00:10]  ngc started ...
[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 [{"filePath":"/Users/os/projects/os-slides/node_modules/@angular/core/core.d.ts","name":"ErrorHandler","members":[]}]
[DEBUG] Error: Internal error: unknown identifier
        [{"filePath":"/Users/os/projects/os-slides/node_modules/@angular/core/core.d.ts","name":"ErrorHandler","members":[]}]
        at Object.importExpr$$1 [as importExpr]
        (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23986:23)
        at tokenExpr (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18406:39)
        at providerDef (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18309:20)
        at /Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18526:77
        at Array.map (native)
        at NgModuleCompiler.compile
        (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18526:44)
        at AotCompiler._compileModule
        (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23920:32)
        at /Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23833:66
        at Array.forEach (native)
        at AotCompiler._compileImplFile
        (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23833:19)

$ npm run ionic:build --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/os/.nvm/versions/node/v7.10.0/bin/node',
npm verb cli   '/Users/os/.nvm/versions/node/v7.10.0/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--verbose' ]
npm info using npm@5.0.4
npm info using node@v7.10.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle os-slides@0.0.1~preionic:build: os-slides@0.0.1
npm info lifecycle os-slides@0.0.1~ionic:build: os-slides@0.0.1

> os-slides@0.0.1 ionic:build /Users/os/projects/os-slides
> ionic-app-scripts build

[22:00:47]  ionic-app-scripts 1.3.12
[22:00:47]  build dev started ...
[22:00:47]  clean started ...
[22:00:47]  clean finished in 1 ms
[22:00:47]  copy started ...
[22:00:47]  transpile started ...
[22:00:49]  transpile finished in 2.12 s
[22:00:49]  preprocess started ...
[22:00:49]  deeplinks started ...
[22:00:49]  deeplinks finished in 32 ms
[22:00:49]  preprocess finished in 32 ms
[22:00:49]  webpack started ...
[22:00:50]  copy finished in 2.27 s
[22:00:59]  webpack finished in 9.61 s
[22:00:59]  sass started ...
[22:01:00]  sass finished in 901 ms
[22:01:00]  postprocess started ...
[22:01:00]  postprocess finished in 3 ms
[22:01:00]  lint started ...
[22:01:00]  build dev finished in 12.71 s
[22:01:12]  lint finished in 11.59 s
npm verb lifecycle os-slides@0.0.1~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle os-slides@0.0.1~ionic:build: PATH: /Users/os/.nvm/versions/node/v7.10.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/os/projects/os-slides/node_modules/.bin:/Users/os/.nvm/versions/node/v7.10.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/local/bin:/Users/os/bin:/Users/os/.composer/vendor/bin:/Users/os/Library/Android/sdk/tools:/Users/os/Library/Android/sdk/platform-tools:/Users/os/Library/Android/sdk/build-tools/25.0.2
npm verb lifecycle os-slides@0.0.1~ionic:build: CWD: /Users/os/projects/os-slides
npm info lifecycle os-slides@0.0.1~postionic:build: os-slides@0.0.1
npm verb exit [ 0, true ]
npm info ok

Thanks


#4

Damn, I missed the --prod there. Please run again.


#5

No problem, here it is:

$ npm run ionic:build --verbose --prod
npm info it worked if it ends with ok
npm verb cli [ '/Users/os/.nvm/versions/node/v7.10.0/bin/node',
npm verb cli   '/Users/os/.nvm/versions/node/v7.10.0/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--verbose',
npm verb cli   '--prod' ]
npm info using npm@5.0.4
npm info using node@v7.10.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle os-slides@0.0.1~preionic:build: os-slides@0.0.1
npm info lifecycle os-slides@0.0.1~ionic:build: os-slides@0.0.1

> os-slides@0.0.1 ionic:build /Users/os/projects/os-slides
> ionic-app-scripts build

[22:04:58]  ionic-app-scripts 1.3.12
[22:04:58]  build prod started ...
[22:04:58]  clean started ...
[22:04:58]  clean finished in 3 ms
[22:04:58]  copy started ...
[22:04:58]  ngc started ...
[22:05:00]  ionic-app-script task: "build"
[22:05:00]  Error: Internal error: unknown identifier
            [{"filePath":"/Users/os/projects/os-slides/node_modules/@angular/core/core.d.ts","name":"ErrorHandler","members":[]}]
Error: Internal error: unknown identifier [{"filePath":"/Users/os/projects/os-slides/node_modules/@angular/core/core.d.ts","name":"ErrorHandler","members":[]}]
    at Object.importExpr$$1 [as importExpr] (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23986:23)
    at tokenExpr (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18406:39)
    at providerDef (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18309:20)
    at /Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18526:77
    at Array.map (native)
    at NgModuleCompiler.compile (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:18526:44)
    at AotCompiler._compileModule (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23920:32)
    at /Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23833:66
    at Array.forEach (native)
    at AotCompiler._compileImplFile (/Users/os/projects/os-slides/node_modules/@angular/compiler/bundles/compiler.umd.js:23833:19)
npm verb lifecycle os-slides@0.0.1~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle os-slides@0.0.1~ionic:build: PATH: /Users/os/.nvm/versions/node/v7.10.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/os/projects/os-slides/node_modules/.bin:/Users/os/.nvm/versions/node/v7.10.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/local/bin:/Users/os/bin:/Users/os/.composer/vendor/bin:/Users/os/Library/Android/sdk/tools:/Users/os/Library/Android/sdk/platform-tools:/Users/os/Library/Android/sdk/build-tools/25.0.2
npm verb lifecycle os-slides@0.0.1~ionic:build: CWD: /Users/os/projects/os-slides
npm info lifecycle os-slides@0.0.1~ionic:build: Failed to exec ionic:build script
npm verb stack Error: os-slides@0.0.1 ionic:build: `ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/Users/os/.nvm/versions/node/v7.10.0/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at EventEmitter.emit (events.js:194:7)
npm verb stack     at ChildProcess.<anonymous> (/Users/os/.nvm/versions/node/v7.10.0/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:194:7)
npm verb stack     at maybeClose (internal/child_process.js:899:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid os-slides@0.0.1
npm verb cwd /Users/os/projects/os-slides
npm verb Darwin 16.6.0
npm verb argv "/Users/os/.nvm/versions/node/v7.10.0/bin/node" "/Users/os/.nvm/versions/node/v7.10.0/bin/npm" "run" "ionic:build" "--verbose" "--prod"
npm verb node v7.10.0
npm verb npm  v5.0.4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! os-slides@0.0.1 ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the os-slides@0.0.1 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/os/.npm/_logs/2017-06-30T20_05_00_372Z-debug.log

#6

Thanks. Unfortunately no additional useful information.

Try searching here: https://github.com/ionic-team/ionic-app-scripts/issues If you don’t find anything, create a ticket there.


#7

Thanks for looking into it. I’ll wait for the next update. Who knows!


#8

Can you please post app.module.ts?


#9

There you go:

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp, { mode: 'ios' })
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: [ErrorHandler], useClass: IonicErrorHandler }
  ]
})
export class AppModule { }

I don’t think there’s anything fishy in there?


#10

The square brackets around “ErrorHandler” look fishy to me.


#11

Oh no. Errors like that without any line context are driving me nuts. --prod runs fine now. :frowning: Sorry for wasting your time.


#12

Well, isn’t that why we all love JavaScript based development so much? :wink:

@rapropos, this was just “doesn’t look right”, correct?


#13

A combination of seeing this in the initial reported error message:

“name”:“ErrorHandler”

…which is generally referenced in the app module, along with this issue discussion (found by searching for “ngc internal error unknown identifier”) which discussed unusual provider syntax made me suspect something amiss in the app module, especially involving ErrorHandler.


#14

Ahh, now I see it in the initial error message. Didn’t connect for me back then.


#15

I was thinking it might be syntax but was looking for a familiar string of one of my own modules. That generic thing threw me off the path. But hey, the more you know. It’s just a bit annoying that these errors can’t be picked up in a more readable manner. But I assume making a recursive search in the sourcecode should be the first thing to do. Didn’t knew however that this even could be considered a syntax error. I usually run a prod build once in a while because I know exactly that it will choke on something somewhere. But that just went by me in this case.