Ionic build ---prod ngc error

CLI just shows "TypeError: Cannot read property ‘text’ of undefined
Right after “ngc started …”

image

I’m getting this error and have no idea how to fix it. I already looked through all similar problems on forum and googled it but no one of proposed solutions helped.

Here is my package.json:

"scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "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/date-picker": "^4.1.0",
        "@ionic-native/google-plus": "^4.2.1",
        "@ionic-native/in-app-browser": "^4.2.1",
        "@ionic-native/keyboard": "^4.2.0",
        "@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-plugin-console": "^1.0.5",
        "cordova-plugin-datepicker": "^0.9.3",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-googleplus": "^5.1.1",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "immutable": "^3.8.1",
        "ionic-angular": "3.6.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "lodash": "^4.17.4",
        "pluralize": "^5.0.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.1.3",
        "@types/lodash": "^4.14.74",
        "faker": "^4.1.0",
        "ionic": "3.9.2",
        "typescript": "2.3.4"
    }

and tsconfig:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

Also get this with ionic build or ionic build --prod?
(Add --verbose to the command to maybe get some additional output)

1 Like

Thanks yout very much for --verbose, now I at least can try to trace what’s going wrong! In case of presenting --prod modifier ngc is starting and ionic build --prod show such error:

ionic build is not invoking ngc so there is no error

1 Like

I don’t see @angular/tsc-wrapped in your package-json. Did I miss it? Mine is at ^4.3.5.

Nope the problem wasn’t there. After additional investigation I have found such lines in my HttpService providing factory:

import { HttpService } from './http.service';

export default function (xhrBackend, requestOptions, authService) {
    return new HttpService(xhrBackend, requestOptions, authService);
}

they were causing the error. Thank you very much for your help, guys!

Can you please elaborate, what exactly was the problem?

having also same problem in --prod mode , if someone could put light on it :