I updated my angular to v9 and when I try to go back in v8, I receive this error. I have already tried the following:
Instead of deleting the whole node_modules folders, just rename it and try
npm install
sudo npm install --unsafe-perm //for macOS
Please find below my angular packages versions -
"@angular-devkit/build-angular": "0.802.0",
"@angular-devkit/core": "8.2.0",
"@angular/animations": "8.2.0",
"@angular/cli": "8.2.0",
"@angular/common": "8.2.0",
"@angular/compiler": "8.2.0",
"@angular/compiler-cli": "8.2.0",
"@angular/core": "8.2.0",
Run also npm i @angular-builders/custom-webpack@8.4.1 --save
For me Occian's answer was not enough, I also had to change @angular-builders/custom-webpack
from latest
to 8.4.1
, because it had build-angular
dependency too. This is how to figure it out:
npm list @angular-devkit/build-angular
reports-web-client@0.0.0 C:\projects\2778\reports-web-client +-- @angular-builders/custom-webpack@9.1.0 | `-- @angular-devkit/build-angular@0.901.1 `-- @angular-devkit/build-angular@0.803.8
Which meant, I had 2 versions of the package, and that's why the error would still show up.
Personally, the best solution is:
ng update @angular/cli @angular/core
Why? Because sooner or later, you need to upgrade to Angular 9+ and the other solutions are only to downgrade it.
I was facing the same issue today until I used this solution and this one works perfectly well.
If you use npm audit fix, find the package which you tried to fix and restore to a stable version and be aware with vulnerabilities.