How to compile Ionic in prod mode for iOS?

When I trying to compile my project with --prod like ionic cordova build ios --prod for iOS I get this error.

[14:25:29]  ngc started ... 
TypeError: Cannot read property 'flags' of undefined
    at checkUnreachable (/Client/node_modules/typescript/lib/typescript.js:24905:31)
    at bindChildrenWorker (/Client/node_modules/typescript/lib/typescript.js:23111:17)
    at bindChildren (/Client/node_modules/typescript/lib/typescript.js:23055:17)
    at bind (/Client/node_modules/typescript/lib/typescript.js:24319:21)
    at bindSourceFile (/Client/node_modules/typescript/lib/typescript.js:22689:17)
    at Object.bindSourceFile (/Client/node_modules/typescript/lib/typescript.js:22640:9)
    at initializeTypeChecker (/Client/node_modules/typescript/lib/typescript.js:47988:20)
    at Object.createTypeChecker (/Client/node_modules/typescript/lib/typescript.js:27142:9)
    at getDiagnosticsProducingTypeChecker (/Client/node_modules/typescript/lib/typescript.js:69678:93)
    at emitWorker (/Client/node_modules/typescript/lib/typescript.js:69722:32)
cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.5
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2


    ios-deploy : 1.9.2 
    ios-sim    : 5.0.13 
    Node       : v9.3.0
    npm        : 5.6.0 
    OS         : OS X El Capitan
    Xcode      : Xcode 8.2.1 Build version 8C1002 

Environment Variables:

    ANDROID_HOME : not set


    backend : pro

Remove angular/cli from package.json. Should be in devDependencies. Then rm -r node_modules and reinstall all your packages with npm i. This worked for me.


I have the same issue. Did you solve it ?