9

When I run ng build --prod get this error. It can serve without error but it can't build. I relay tied with that

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)

My dependencies:

"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",
    .....
  }

How to solve this error?

4
  • Why are you using v7 of the Angular CDK which is intended for applications using Angular v7, instead of updating to v8 of the Angular CDK? Commented Dec 26, 2019 at 14:21
  • 1
    i update it to v8 but it not helpful Commented Dec 26, 2019 at 14:50
  • 1
    You should also update the other Angular dependencies that are targeting v7 of the Angular framework. Commented Dec 26, 2019 at 15:28
  • i update all dependencies one by one . but it get same error Commented Dec 26, 2019 at 21:56

3 Answers 3

2

The discussion at https://github.com/webpack-contrib/mini-css-extract-plugin/issues/186 includes a statement that this error occurs when any component has a styleUrls property whose array value has a length greater than 1.

I verified this in an application where reducing the value of this property to an array of length 1 made the error disappear.

Sign up to request clarification or add additional context in comments.

Comments

1

in my case some css not work properly that's why get this error.it found when i check one by one. because this error hidden other errors.

Comments

0

I had this error because I've made a mistake of putting "" is styles list in angular.json file. I wanted to add css file and started typing but I made it the other way and I left this "" there.

"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 */
],

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.