我想一些帮助与建设我的Angular 7和离子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应用程序,所以我还在学习...我做错了什么吗?我应该使用不同的构建命令吗?
1条答案
按热度按时间6kkfgxo01#
在开发我的第一个Angular应用程序时,我一直在处理这个问题。在互联网上找不到如何处理这个问题的地方,我尝试过,但没有解决这个错误。直到我进入生产(在生产中,这个错误似乎根本没有出现),然后我发现了buildOptimizer。
我们当时正在开发angular 7应用程序--我的Angular是全球13.0版本,所以出现了版本不匹配的问题--在我同事的电脑上,他安装了ang 7,但也没有收到错误。所以我想这是因为版本不匹配。
这里包含angular.json的片段,在这里可以找到buildOptimizer。注意,你必须将它从true改为false。
angular.json