TypeError: Cannot read property 'flags' of undefined

11,615

Solution 1

Removing @angular/cli should work for you

if not, change Typescript version to ~2.6.2.

@angular/cli 1.7.3 works with Typescript ~2.6.2 only.

Solution 2

Installing angular 9.0.0 solved the problem for me

npm install @angular/[email protected] -g

it was breaking for angular 9.1.5

Solution 3

I'm using angular 5 and ionic v3. For me work these changes:

"@types/node": "^9.6.55",
"typescript": "3.7.4",
"@ionic/app-scripts": "3.2.3",

If your are using @angular/cli or @angular-devkit, in my case I had to remove it in order to build with --prod tag properly.

Be sure also to remove your node_modules and do npm cache clean -f, then npm i (maybe will be good also remove your package-lock.json)

Share:
11,615

Related videos on Youtube

Weshen
Author by

Weshen

Updated on September 16, 2022

Comments

  • Weshen
    Weshen over 1 year

    After cloning a repo, npm install && ionic cordova build android --prod shows me following error.

    TypeError: Cannot read property 'flags' of undefined
        at checkUnreachable (F:\Works\Projects\ionic-bokfinder\node_modules\typescript\lib\typescript.js:24905:31)
        at bindChildrenWorker (F:\Works\Projects\ionic-bokfinder\node_modules\typescript\lib\typescript.js:23111:17)
        at bindChildren (F:\Works\Projects\ionic-bokfinder\node_modules\typescript\lib\typescript.js:23055:17)
        at bind (F:\Works\Projects\ionic-bokfinder\node_modules\typescript\lib\typescript.js:24319:21)
        at bindSourceFile
    

    I am sure it worked well without any problems before. Here are my system information and package.json.

    System:

        Node : v8.10.0
        npm  : 5.6.0
        OS   : Windows 10
    

    Package.json:

    "dependencies": {
        "@angular/common": "5.0.3",
        "@angular/compiler": "5.0.3",
        "@angular/compiler-cli": "5.0.3",
        "@angular/core": "5.0.3",
        "@angular/forms": "5.0.3",
        "@angular/http": "5.0.3",
        "@angular/platform-browser": "5.0.3",
        "@angular/platform-browser-dynamic": "5.0.3",
        "@ionic-native/core": "^4.5.2",
        "@ionic-native/facebook": "^4.5.2",
        "@ionic-native/firebase": "^4.5.2",
        "@ionic-native/in-app-browser": "^4.5.2",
        "@ionic-native/in-app-purchase": "^4.5.2",
        "@ionic-native/intercom": "^4.5.2",
        "@ionic-native/social-sharing": "^4.5.2",
        "@ionic-native/splash-screen": "4.4.0",
        "@ionic-native/status-bar": "4.4.0",
        "@ionic/storage": "2.1.3",
        "angularfire2": "^5.0.0-rc.6",
        "firebase": "^4.12.0",
        "ionic-angular": "3.9.2",
        "ionicons": "3.0.0",
        "raven-js": "^3.17.0",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "zone.js": "^0.8.18"
      },
      "devDependencies": {
        "@angular/cli": "^1.7.3",
        "@ionic/app-scripts": "^3.1.8",
        "@types/jasmine": "2.8.4",
        "@types/node": "9.3.0",
        "html-loader": "0.5.5",
        "istanbul-instrumenter-loader": "3.0.0",
        "jasmine": "2.9.0",
        "jasmine-spec-reporter": "4.2.1",
        "karma": "2.0.0",
        "karma-chrome-launcher": "2.2.0",
        "karma-coverage-istanbul-reporter": "1.3.3",
        "karma-jasmine": "1.1.1",
        "karma-jasmine-html-reporter": "0.2.2",
        "karma-sourcemap-loader": "0.3.7",
        "karma-webpack": "2.0.9",
        "protractor": "5.2.2",
        "ts-loader": "3.2.0",
        "ts-node": "4.1.0",
        "tslint": "5.9.1",
        "typescript": "2.4.2"
      },
    

    I guess this problem is related with @ionic/app-scripts issue.

  • Weshen
    Weshen about 6 years
    Wow, so quick response! Worked me perfectly.
  • thefoyer
    thefoyer almost 3 years
    Angular 5 ionic 3 here too. This fixed it for me, thanks man. Until the next thing breaks. Can't wait to rewrite this app.