当我运行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:\project\tea supply chain mangement system\test2\node_modules\webpack\lib\RequestShortener.js:16:17)
at new RequestShortener (C:\project\tea supply chain mangement system\test2\node_modules\webpack\lib\RequestShortener.js:26:15)
at new Compiler (C:\project\tea supply chain mangement system\test2\node_modules\webpack\lib\Compiler.js:195:27)
at Compiler.createChildCompiler (C:\project\tea supply chain mangement system\test2\node_modules\webpack\lib\Compiler.js:548:25)
at Compilation.createChildCompiler (C:\project\tea supply chain mangement system\test2\node_modules\webpack\lib\Compilation.js:2100:24)
at Object.pitch (C:\project\tea supply chain mangement system\test2\node_modules\@angular-devkit\build-angular\node_modules\mini-css-extract-plugin\dist\loader.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",
.....
}如何解决这个错误?
发布于 2019-12-27 19:12:27
在我的例子中,有些css不能正常工作,这就是为什么在我逐一检查时找到这个error.it的原因。因为这个错误隐藏了其他错误。
发布于 2020-01-11 19:03:16
https://github.com/webpack-contrib/mini-css-extract-plugin/issues/186上的讨论包括这样一条语句:当任何组件具有数组值大于1的styleUrls属性时,都会发生此错误。
我在一个应用程序中验证了这一点,该应用程序将此属性的值降为长度为1的数组,从而使错误消失。
发布于 2021-04-25 08:32:42
我犯了这个错误,因为我在angular.json文件中放置了"“is样式列表。我想要添加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 */
],https://stackoverflow.com/questions/59489609
复制相似问题