Angular 7 + Ionic 4 build failing "TypeError: Cannot read properties of undefined (reading 'kind')"

Angular 7 + Ionic 4 build failing "TypeError: Cannot read properties of undefined (reading 'kind')"

我需要一些帮助来解决构建我的 Angular 7 和 Ionic 4 应用程序的问题...

如果我 运行 ng build --prod 命令出现以下错误:

ERROR in ./node_modules/ionic4-auto-complete/fesm5/ionic4-auto-complete.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read properties of undefined (reading 'kind')
    at isAngularDecoratorMetadataExpression (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:265:35)
    at checkNodeForDecorators (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:77:21)
    at visitNodes (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16144:30)
    at Object.forEachChild (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16370:24)
    at checkNodeForDecorators (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:68:31)
    at visitNode (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16135:24)
    at Object.forEachChild (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16265:21)
    at checkNodeForDecorators (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:68:31)
    at visitNode (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16135:24)
    at Object.forEachChild (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16322:24)
    at checkNodeForDecorators (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:68:31)
    at visitNode (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16135:24)
    at Object.forEachChild (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16333:24)
    at checkNodeForDecorators (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\src\transforms\scrub-file.js:68:31)
    at visitNode (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16135:24)
    at Object.forEachChild (C:\MAMP\htdocs\myProject\employeeApp\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16229:21)

这是我的 package.json 文件:

"@angular/animations": "^11.0.7",
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@auth0/angular-jwt": "^3.0.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.1.0",
"@ionic/storage": "^2.2.0",
"cordova-android": "^8.0.0",
"cordova-browser": "6.0.0",
"cordova-sqlite-storage": "^3.3.0",
"core-js": "^2.5.4",
"ionic4-auto-complete": "^2.8.2",
"moment": "^2.24.0",
"ng2-date-picker": "^2.11.0",
"rxjs": "~6.5.1",
"sass": "^1.49.9",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"

我已经在谷歌上搜索这个问题几个小时了,但不知道该怎么做。这是我的第一个 Angular + Ionic 应用程序,所以我还在学习中...我做错了什么?我应该使用不同的构建命令吗?

在开发我的第一个 Angular 应用程序时,我一直在处理这个问题。网上没查到怎么处理这个问题,我试了没解决这个错误。直到我进入生产环境(错误似乎根本没有出现),然后我发现了 buildOptimizer.

我们正在开发 angular 7 应用程序 - 我有 Angular 的全球版本 13.0,所以版本不匹配 - 在我同事的电脑上,他安装了 ang7,他也没有得到错误。所以我假设这是因为版本不匹配。

此处包含 angular.json 的片段,在哪里可以找到 buildOptimizer。请注意,您必须将其从 true 更改为 false.

angular.json