qubits
qubits

Reputation: 1307

Missing material dependencies after upgrade to Angular 9

I followed the upgrade guide to migrate Angular from 8.2 to 9.1. I am also using Angular material which as per the guide I also updated. I also made sure all other packages are at Wanted version.

Whenever I try to run the solution I get:

ERROR in The target entry-point "@angular/material/core" has missing dependencies:
 - @angular/core
 - @angular/platform-browser
 - rxjs
 - rxjs/operators
 - @angular/platform-browser/animations
 - @angular/common
 - @angular/forms

There are no outdated packages as checked with npm outdated.

All angular packages have been updated to the latest with ng update and just to be sure I cleared the cache with npm cache clear --force.

The version of @angular/core is at "@angular/core": "^9.1.11" and material at "^9.2.4".

I am assuming material depends on a different version of core but don't understand why it would install it by default with ng-cli and what version to install if its not the right one

Upvotes: 1

Views: 9255

Answers (4)

adamdport
adamdport

Reputation: 12613

I had a similar error while updating node modules on my project, only the error was in an in-house library that my project consumes. I ended up discovering that Angular was dependent on an older version of rxjs than the library (that I'd just updated). Downgrading rxjs to match what Angular was pulling in resolved the issue for me.

Upvotes: 0

JoaVer
JoaVer

Reputation: 83

Perhaps this can give some insight:

I had the same problem but in my case the error occured in a package I build i.e. package X.

I was able to solve the problem in package X by:

  1. Removing package-lock.json
  2. Running command npm cache clean --force
  3. Rebuilding package

Then in the project where i wanted to use package X:

  1. npm install Package X

Problem was solved

Upvotes: 0

Aakash Garg
Aakash Garg

Reputation: 10979

Follow following steps :-

  1. Delete node_modules folder.
  2. Delete package-lock.json file.
  3. Run npm cache clean --force
  4. Run npm install --save @angular/material @angular/cdk

Then try to run your project.

Upvotes: 2

yeerk
yeerk

Reputation: 2687

Try using yarn (version 1, not version 2) https://classic.yarnpkg.com/en/docs/install/#windows-stable.

Yarn has very good compatibility with npm, but uses a completely different module cache folder, and does additional node_modules checks to make sure your modules are in the correct state.

Yarn may not be an entirely satisfactory solution to your problem, however it is not unusual for some people on a project to use yarn, and some to use npm, due to the high compatibility between them.

Upvotes: 0

Related Questions