typescript - Angular cli build prod: TypeError: Kan inte läsa egenskapen 'kind' av undefined
Jag försöker bygga projekt med Angular CLI ng build --prod och jag får detta fel:
FEL i TypeError: Kan inte läsa egenskapen 'kind' av undefined
om jag bygger utan --prod får jag inget fel
Fullständig fel:
ERROR in TypeError: Cannot read property 'kind' of undefined
at isParameterPropertyDeclaration (node_modules/typescript/lib/typescript.js:13445:88)
at Object.filter (node_modules/typescript/lib/typescript.js:469:31)
at transformClassMembers (node_modules/typescript/lib/typescript.js:70813:20)
at createClassDeclarationHeadWithoutDecorators (node_modules/typescript/lib/typescript.js:70665:110)
at visitClassDeclaration (node_modules/typescript/lib/typescript.js:70584:19)
at visitTypeScript (node_modules/typescript/lib/typescript.js:70432:28)
at visitorWorker (node_modules/typescript/lib/typescript.js:70227:24)
at sourceElementVisitorWorker (node_modules/typescript/lib/typescript.js:70252:28)
at saveStateAndInvoke (node_modules/typescript/lib/typescript.js:70165:27)
at sourceElementVisitor (node_modules/typescript/lib/typescript.js:70237:20)
at visitNodes (node_modules/typescript/lib/typescript.js:67751:48)
at Object.visitLexicalEnvironment (node_modules/typescript/lib/typescript.js:67784:22)
at visitSourceFile (node_modules/typescript/lib/typescript.js:70521:53)
at saveStateAndInvoke (node_modules/typescript/lib/typescript.js:70165:27)
at transformSourceFile (node_modules/typescript/lib/typescript.js:70147:27)
at transformSourceFileOrBundle (node_modules/typescript/lib/typescript.js:70127:20)
Angular-version:
Angular CLI: 8.3.3
Node: 12.9.0
OS: darwin x64
Angular: 9.0.0-next.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.900.0-next.3
@angular-devkit/build-angular 0.900.0-next.3
@angular-devkit/build-optimizer 0.900.0-next.3
@angular-devkit/build-webpack 0.900.0-next.3
@angular-devkit/core 9.0.0-next.3
@angular-devkit/schematics 8.3.3
@angular/cdk 8.1.4
@angular/cli 8.3.3
@angular/http 8.0.0-beta.10
@angular/material 8.1.4
@angular/material-moment-adapter 8.1.4
@ngtools/webpack 9.0.0-next.3
@schematics/angular 8.3.3
@schematics/update 0.803.3
rxjs 6.5.3
typescript 3.6.3
webpack 4.39.3
Tack.
Svar #1
Tänk på att TypeScript 3.6.4 är ute. Det är fortfarande okej att läsa nedan vad som egentligen inte fungerade.
TypeScript <= 3.6.3 har detta problem, hantera nod utan förälder i isParameterPropertyDeclaration.
Om du installerar 3.7 (dev eller den nya beta), kommer det att kompilera utan problem.
Obs: om du får ett ERROR vid byggning, angående TS-versionen, inaktivera det bara via tsconfig.
För det, använd disableTypeScriptVersionCheck
"angularCompilerOptions": {
"disableTypeScriptVersionCheck": true
},
"compilerOptions": {
...
Följ kommentarschatten om något annat problem uppstår.
Svar #2
Detta problem uppstår i så många fall, en av de största anledningarna är att den installerade versionen av @angular/cli är olika den globalt installerade versionen av @angular/cli. Se till att båda är samma version. I andra fall måste du uppdatera devkit.
Vänligen ta en titt på dessa trådar, du kommer att få en uppfattning:
- https://github.com/angular/angular-cli/issues/13172
- https://github.com/angular/angular-cli/issues/13861
