Ionic 3.x Unable to build using the --prod "TypeError: Cannot read property 'kind' of undefined"

Hello,
So I have an issue, that I have seen on a few different posts, where I am unable to build using --prod. Regular builds work fine as does using --release.

I am able to create a new project, install a platform and build using prod, so the issue is related to the project for sure. So far I have tried a number of things such as removing platforms/www/modules, re-installing ionic, node, updating typescript.

I am little lost on where to look next, or rather what I am looking for to fix this. Any help would be great thanks!

[08:09:23]  build prod started ...
[08:09:23]  clean started ...
[08:09:23]  clean finished in 2 ms
[08:09:23]  copy started ...
[08:09:23]  deeplinks started ...
[08:09:25]  deeplinks finished in 1.63 s
[08:09:25]  ngc started ...
TypeError: Cannot read property 'kind' of undefined
    at nodeCanBeDecorated (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8376:36)
    at nodeIsDecorated (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8396:16)
    at Object.nodeOrChildIsDecorated (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8400:16)
    at isDecoratedClassElement (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53700:23)
    at isInstanceDecoratedClassElement (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53691:20)
    at Object.filter (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:1687:31)
    at getDecoratedClassElements (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53673:23)
    at generateClassElementDecorationExpressions (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53847:27)
    at addClassElementDecorationStatements (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53836:44)
    at visitClassDeclaration (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53162:13)
[DEBUG] TypeError: Cannot read property 'kind' of undefined
            at nodeCanBeDecorated
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8376:36)
            at nodeIsDecorated
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8396:16)
            at Object.nodeOrChildIsDecorated
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:8400:16)
            at isDecoratedClassElement
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53700:23)
            at isInstanceDecoratedClassElement
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53691:20)
            at Object.filter
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:1687:31)
            at getDecoratedClassElements
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53673:23)
            at generateClassElementDecorationExpressions
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53847:27)
            at addClassElementDecorationStatements
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53836:44)
            at visitClassDeclaration
        (/Users/xxxxx/Desktop/ebox-ionic/node_modules/typescript/lib/typescript.js:53162:13)

Ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.10
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.0.2
    ios-deploy        : 1.9.2
    Node              : v8.10.0
    npm               : 5.8.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.4.1 Build version 9F2000

Environment Variables:

    ANDROID_HOME : /Users/xxxxx/Library/Android/SDK

Misc:

    backend : pro

and package.json

{
  "name": "ebox-ionic",
  "version": "0.0.2",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "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"
  },
  "config": {
    "ionic_webpack": "./config/webpack.config.js"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/android-fingerprint-auth": "^4.7.0",
    "@ionic-native/app-version": "^4.7.0",
    "@ionic-native/camera": "^4.7.0",
    "@ionic-native/core": "^4.7.0",
    "@ionic-native/date-picker": "^4.7.0",
    "@ionic-native/geolocation": "^4.7.0",
    "@ionic-native/google-maps": "^4.8.2",
    "@ionic-native/http": "^4.7.0",
    "@ionic-native/in-app-browser": "^4.7.0",
    "@ionic-native/network": "^4.7.0",
    "@ionic-native/screen-orientation": "^4.7.0",
    "@ionic-native/secure-storage": "^4.7.0",
    "@ionic-native/splash-screen": "4.6.0",
    "@ionic-native/sqlite": "^4.7.0",
    "@ionic-native/status-bar": "^4.7.0",
    "@ionic/pro": "^1.0.20",
    "@ionic/storage": "2.1.3",
    "asmcrypto.js": "^0.22.0",
    "cordova-android": "7.0.0",
    "cordova-browser": "5.0.3",
    "cordova-plugin-advanced-http": "^1.11.1",
    "cordova-plugin-android-fingerprint-auth": "^1.4.3",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-datepicker": "^0.9.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-googlemaps": "^2.3.4",
    "cordova-plugin-inappbrowser": "^2.0.2",
    "cordova-plugin-ionic": "^4.1.7",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-media-capture": "^3.0.2",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-screen-orientation": "~3.0.1",
    "cordova-plugin-secure-storage": "^2.6.8",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.3.2",
    "ionic-angular": "3.9.2",
    "ionic-img-viewer": "^2.9.0",
    "ionic2-super-tabs": "^4.2.2",
    "ionicons": "3.0.0",
    "minimist": "^1.2.0",
    "moment": "^2.22.1",
    "reflect-metadata": "^0.1.12",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "typeorm": "^0.2.7",
    "xml2js": "^0.4.19",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.1.10",
    "@types/node": "^9.6.21",
    "sql.js": "^0.5.0",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-android-fingerprint-auth": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-secure-storage": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-ionic": {
        "APP_ID": "123",
        "CHANNEL_NAME": "123",
        "UPDATE_METHOD": "auto",
        "MAX_STORE": "2",
        "WARN_DEBUG": "true",
        "UPDATE_API": "https://api.ionicjs.com"
      },
      "cordova-plugin-statusbar": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-media-capture": {},
      "cordova-plugin-datepicker": {},
      "cordova-plugin-screen-orientation": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "123",
        "PLAY_SERVICES_VERSION": "15.0.1",
        "ANDROID_SUPPORT_V4_VERSION": "26.1.0"
      }
    },
    "cordova-plugin-advanced-http": {},
    "platforms": [
      "browser",
      "android"
    ]
  },
  "platforms": [
    "android"
  ]
}

Maybe downgrading angular to v5.0.0 and typescript to v2.4.2?

I will give it go, thanks.
I was however able to create a new project, that had the same versions as the above and was able to build in prod.

1 Like

Given the discussion in here, these two dependencies are the first place I would start investigating.

1 Like

Excellent, I will investigate. Thanks alot.

Hi, I had the same issue: after many investigations :roll_eyes: , I resolved with downgrade typescript to 2.7.1 :

npm install typescript@2.7.1

Had similar problem. Had to reinstall @angular/cli using yarn. Check this topic https://github.com/palantir/tslint/issues/3689

1 Like