It seems to be a problem with @angular-devkit/build-angular.
Try updating it by running
npm i @angular-devkit/build-angular
Or downgrading it by specifying a previous version, such as
npm i @angular-devkit/[email protected]
I had this error after npm audit
found vulnerabilities in the version of @angular-devkit/build-angular
that I was using. I ran npm audit fix
which updated it to 0.900.2
, but when I ran ng serve
it gave the error quoted in the question.
I resolved it by downgrading to version 0.803.25
. This was the highest version I could find which did not cause any errors when running ng serve
. The vulnerabilities found by npm audit
are resolved in this version.
This is the command I ran:
npm i @angular-devkit/[email protected]
I had just created a new project and got this error. Since I had no legacy code I needed to work with and wanted to use the latest (9.0) version of Angular, I ran this command:
ng update @angular/cli @angular/core
and it fixed everything.
update @angular-devkit/build-angular version .
Try deleting package-lock.json
and reinstalling node_modules
I had the same issue in Ionic 4 after running "npm audit fix", but npm broke the whole versioning of the dependencies.
I tried doing most of the things listed here but it would fix one problem and create a new one. So the only solution that worked for me was manual dependency handling.
Check out what versions of each package you need in your package.json and package-lock.json (which package version do other packages depend on and expect to find in your project, mine were expecting about three total versions of some files), some will be shown as warnings in your cli after npm installing some packages, but not all will show so do best to manually check.
NB: I found package-lock.json easier for me to read but I would refer to package.json to make sure I was still on the right track.
For me the main package was Ionic itself (@ionic/angular-toolkit was the only package I could find that was connected to angular), so I looked at the version of angular it was expecting and downgraded to that. Then every other package that angular needed also had to be checked. It was a lot of work and spent half a day fixing but it solved all my issues.
Focusing on the angular package, I decided to npm install @schematics/[email protected]
That dependency, @schematics/[email protected], had the following dependencies;
The dependency, @angular-devkit/[email protected] had the dependencies;
I did this for all the packages until I could build my app again. But you can just install in one go if you know the versions they require npm install @schematics/[email protected] @angular-devkit/[email protected] @angular-devkit/[email protected]
You can put all the packages in that npm install line if you already know for certain which other packages should be downgraded or upgraded to save time.
Hope this helps anyone who couldn't find a solution from the other comments.
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