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?
Further you can try to re-install Angular cli to fix Could not find module @angular-devkit/build-angular error. Follow the below steps to re-install Angular CLI.
So if you upgrade your application from older version of Angular to Angular 6 or higher, there is a chance that you will get this error. Unfortunately there is no straight way to fix this issue.
1st Step: Open the node_modules folder present in the project. 2nd Step: check for the folder @build-angular. 3rd Step: if the folder is not present then try to install @angular-devkit/build-angular using following command in command prompt. npm i.
But our local Angular application will have older versions of packages installed in node_modules folder. So delete the node_modules folder manually from the application directory. After that clear the cache using npm cache clean --verify. And then run npm install command.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With