后缺少材料依赖项

后缺少材料依赖项

本文介绍了升级到 Angular 9 后缺少材料依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照升级指南将 Angular 从 8.2 迁移到 9.1.我也在使用 Angular 材料,根据我也更新的指南.我还确保所有其他软件包都是通缉版本.

每当我尝试运行解决方案时,我都会得到:

目标入口点@angular/material/core"中的错误缺少依赖项:- @角度/核心- @angular/platform-b​​rowser- rxjs- rxjs/运营商- @angular/platform-b​​rowser/animations- @angular/common- @angular/表格

使用 npm outdated 检查没有过时的软件包.

所有 angular 包都已通过 ng update 更新到最新版本,只是为了确保我使用 npm cache clear --force 清除了缓存.

@angular/core 的版本在 "@angular/core": "^9.1.11" 和 material 在 "^9.2.4".

我假设材料依赖于不同版本的核心,但不明白为什么默认情况下会使用 ng-cli 安装它,以及如果它不正确要安装什么版本

解决方案

按照以下步骤操作:-

  1. 删除 node_modules 文件夹.
  2. 删除 package-lock.json 文件.
  3. 运行 npm cache clean --force
  4. 运行 npm install --save @angular/material @angular/cdk

然后尝试运行您的项目.

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

解决方案

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.

这篇关于升级到 Angular 9 后缺少材料依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 22:45