ng build 抛出“无法读取未定义属性‘种类’中的错误”

问题描述

所以我有一个项目需要我使用 ng build --prod 来构建客户端。当我运行 ng build --prod 时,我每次都遇到相同的错误

ERROR in Cannot read property 'kind' of undefined

这个错误每次都会发生,无论我做什么,经过近一个星期的努力,我似乎​​都无法让客户端正确构建,并且几天都在寻找解决方案。我已将 git 链接附加到客户端,希望有人能够找到并修复此错误。要运行它,只需在下载位置的 Cube 文件夹中npm install,然后运行 ​​ng build --prod。我希望这是一个简单的解决方法

安装客户端的 Github 链接

https://github.com/detis46901/Cube.git

编辑 1: 我查看了 StackOverflow 上的其他问题,例如下面评论中列出的问题 (TypeError: Cannot read property 'kind' of undefined at getAssignmentTargetKind)。这些解决方案似乎不起作用。

解决方法

所以我找到了解决方案。我必须进去编辑 tsconfig.json。

"angularCompilerOptions" 下,我必须添加 "enableIvy": false

"lib" 下,我必须添加 "ES2020""ESNext"

完成后,我需要rm ./node_modules/,然后npm i。然后,我必须安装特定版本的 typescript 和 angular。

npm install [email protected]
npm install @angular-devkit/[email protected]
npm install @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected]

通过这些更改,我终于能够ng build 客户。需要修改的地方我会告诉原github所有者,以便程序更好的使用。