Angular cli build prod:TypeError:无法读取未定义的属性“种类" [英] Angular cli build prod: TypeError: Cannot read property 'kind' of undefined

查看:20
本文介绍了Angular cli build prod:TypeError:无法读取未定义的属性“种类"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 Angular CLI ng build --prod 构建项目,但出现此错误:

I try to build project with Angular CLI ng build --prod and I get this error:

TypeError 中的错误:无法读取未定义的属性种类"

ERROR in TypeError: Cannot read property 'kind' of undefined

如果我不使用 --prod 构建,我不会收到任何错误

if I build with not --prod I do not get any error

完全错误:

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 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

谢谢.

推荐答案

现在请记住 TypeScript 3.6.4 已发布. 不过,阅读下面的内容并没有真正发挥作用是可以的.

Keep in mind now TypeScript 3.6.4 is out. Still, it's ok to read below what wasn't really working.

TypeScript <=3.6.3 提出了这个问题,处理无父级isParameterPropertyDeclaration 中的节点.

TypeScript <= 3.6.3 presents this issue, Handle parentless nodes in isParameterPropertyDeclaration.

如果您安装 3.7(dev 或新的 beta),它会编译正常.

If you install 3.7 (dev or the new beta), it will compile fine.

注意:如果您在构建时收到 ERROR,关于 TS 版本,只需通过 tsconfig 禁用它.
为此使用 disableTypeScriptVersionCheck

Note: if you receive an ERROR on building, regarding the TS version, just disable it via tsconfig.
For that use disableTypeScriptVersionCheck

"angularCompilerOptions": {
  "disableTypeScriptVersionCheck": true
},
"compilerOptions": {
 ...

如果出现任何其他问题,请关注评论的聊天.

Follow the comment's chat if any other problem emerges.

这篇关于Angular cli build prod:TypeError:无法读取未定义的属性“种类"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆