模块构建失败中的错误(来自./node_modules/@angular-devkit/build-angular/no



当我运行时ng build --prod出现此错误。它可以毫无错误地服务,但不能构建。我接力与那个绑在一起

ERROR in Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/mini-css-extract-plugin/dist/loader.js):       
TypeError: Cannot read property 'replace' of undefined
at normalizeBackSlashDirection (C:projecttea supply chain mangement systemtest2node_moduleswebpacklibRequestShortener.js:16:17)  
at new RequestShortener (C:projecttea supply chain mangement systemtest2node_moduleswebpacklibRequestShortener.js:26:15)
at new Compiler (C:projecttea supply chain mangement systemtest2node_moduleswebpacklibCompiler.js:195:27)
at Compiler.createChildCompiler (C:projecttea supply chain mangement systemtest2node_moduleswebpacklibCompiler.js:548:25)        
at Compilation.createChildCompiler (C:projecttea supply chain mangement systemtest2node_moduleswebpacklibCompilation.js:2100:24) 
at Object.pitch (C:projecttea supply chain mangement systemtest2node_modules@angular-devkitbuild-angularnode_modulesmini-css-extract-plugindistloader.js:89:43)

我的依赖项:

"dependencies": {
"@agm/core": "^1.1.0",
"@angular/animations": "8.2.14",
"@angular/cdk": "^8.2.3",
"@angular/common": "8.2.14",
"@angular/compiler": "8.2.14",
"@angular/core": "^8.2.14",
"@angular/http": "^7.2.15",
"@angular/material": "^8.2.3",
"@angular/router": "8.2.14",
....
"web3": "^1.2.4",
"zone.js": "0.9.1"   
},   
"devDependencies": {  
"@angular-builders/custom-webpack": "^8.4.1",
"@angular-builders/dev-server": "^7.3.1",
"@angular-devkit/build-angular": "^0.803.21",
"@angular-devkit/architect": "^0.803.21",
"@angular/cli": "^8.3.21",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "8.2.14",
.....
}

如何解决此错误?

https://github.com/webpack-contrib/mini-css-extract-plugin/issues/186 的讨论包括一条语句,即当任何组件具有数组值长度大于 1 的 styleUrls 属性时,会发生此错误。

我在一个应用程序中验证了这一点,在该应用程序中,将此属性的值减小到长度为 1 的数组会使错误消失。

在我的情况下,某些 CSS 无法正常工作,这就是为什么当我一一检查时找到这个 error.it。 因为此错误隐藏了其他错误。

我有这个错误,因为我错误地将"是angular.json文件中的样式列表。我想添加 css 文件并开始输入,但我以另一种方式制作,我把这个"留在那里。

"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"" /* <--- this line breaks everything */
],

最新更新