angular: TypeError: Cannot read property 'flags' of undefined (ng build --prod)
ng build --prod ERRORS
Console Log:
ERROR in Error: TypeError: Cannot read property 'flags' of undefined
at checkUnreachable (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:24905:31)
at bindChildrenWorker (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:23111:17)
at bindChildren (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:23055:17)
at bind (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:24319:21)
at bindSourceFile (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:22689:17)
at Object.bindSourceFile (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:22640:9)
at initializeTypeChecker (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:47988:20)
at Object.createTypeChecker (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:27142:9)
at getDiagnosticsProducingTypeChecker (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69678:93)
at C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69809:35
at runWithCancellationToken (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69779:24)
at getSemanticDiagnosticsForFileNoCache (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69802:20)
at getAndCacheDiagnostics (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:70033:26)
at getSemanticDiagnosticsForFile (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69799:20)
at getDiagnosticsHelper (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69738:24)
at Object.getSemanticDiagnostics (C:\Users\dunno\Documents\bidipeppercrap\bidipeppercrap.com\index\node_modules\typescript\lib\typescript.js:69751:20)
Current behavior
Can’t do ng build --prod
, see details above.
Expected behavior
Error after upgrading my angular-cli to the latest version.
Minimal reproduction of the problem with instructions
I’ve been searching over the internet and found no solution.
What is the motivation / use case for changing the behavior?
I’ve been delete node_modules and reinstalling it using npm install
.
I’ve been reinstalling TSLint using npm uninstall tslint
& npm install tslint
.
Environment
Package.json:
{
"name": "index",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.5",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.5",
"@angular/compiler": "^5.0.5",
"@angular/core": "^5.0.5",
"@angular/forms": "^5.0.5",
"@angular/http": "^5.0.5",
"@angular/material": "^5.0.0-rc0",
"@angular/platform-browser": "^5.0.5",
"@angular/platform-browser-dynamic": "^5.0.5",
"@angular/router": "^5.0.5",
"angularfire2": "^5.0.0-rc.5-next",
"core-js": "^2.4.1",
"firebase": "^4.7.0",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.3",
"tslint": "^5.8.0",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.5.5",
"@angular/compiler-cli": "^5.0.5",
"@angular/language-service": "^5.0.5",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"typescript": "~2.4.2"
}
}
For Tooling issues:
- Node version: v8.9.1
- Platform: Windows 7
Others:
Code Editor: VSCode
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 15 (1 by maintainers)
I’m sorry, I got my issue solved just now. Thanks.
@briancodes Solution worked for me on node 6.9.1, typescript 2.4.2
Edit: I’ll add that I was encountering this locally when building with the production flag. I encountered it again during the Ionic Pro build process and had to update to Typescript 2.6.2 which has so far seemed to resolve it
I solved removing package-lock.json and “npm install” (typescript 2.4.2)
@Noderino I upgrade every dependency with
npm update
“after” I updated the Angular CLI.update typescript to 2.6.x globally and locally, solved this problem for me.
@bidipeppercrap How did you solve it?
I was trying for over an hour to solve this. @GarryBrown advice on removing the
package.lock.json
, as well as runningnpm cache clean --force
(I’m on npm version >5, but the verify wasn’t fixing it) seemed to do the trick. I’m getting an Angular CLI warning about using latest TypeScript, but that warning will be removed in the next CLI updateNote: I had already done an
npm update
and installed the latest cli as per the GitHub release instructionsI tried to uninstall and reinstall @angular/cli with npm but did not work. Then i installed previous version with
npm install @angular/cli@1.5.4 --save-dev
and it worked. Strange thing is; I installed latest version again (v1.5.5) and it compiled without error.I was getting this error while using “tslint”: “5.5.0” (in my package.json) When I upgraded to the latest “tslint”: “5.11.0” I had NO more this error (ERROR in Error: TypeError: Cannot read property ‘flags’ of undefined)
The new tslint gives warning to remove ‘–type-check’ (if you have run tslint with this flag) because the flag is deprecated and after that everything is fine!
Good luck!