目标入口点“ @ angular / cdk / platform”缺少依赖项

问题描述

我有一个版本为8的Angular应用程序。我更新到了9。我解决了所有编译和linter错误,但其中一个给我带来了一些问题:

ERROR in The target entry-point "@angular/cdk/platform" has missing dependencies:

@angular/core
@angular/common

这些是我package.json中的有角度的包:

        "@angular/animations": "10.0.12","@angular/cdk": "10.1.3","@angular/common": "10.0.12","@angular/compiler": "10.0.12","@angular/core": "10.0.12","@angular/flex-layout": "10.0.0-beta.32","@angular/forms": "10.0.12","@angular/material": "10.1.3","@angular/platform-browser": "10.0.12","@angular/platform-browser-dynamic": "10.0.12","@angular/router": "10.0.12",

我尝试删除node_modules,package-lock.json,重新安装等。

我认为这可能与ivy编译器有关,但它正在编译所有内容(我认为):

> ngcc --tsconfig './src/tsconfig.app.json' && bash post-install-checks.sh

Compiling @angular/cdk/platform : fesm2015 as esm2015
(and others)

什么会导致这种类型的错误?我想念什么?

还有一些我发现的错误

/myDevFolder/my-app/node_modules/@types/d3-shape/index.d.ts
Error:(2273,19) TS2304: Cannot find name 'CanvasPathMethods'.
/myDevFolder/my-app/node_modules/protractor/built/index.d.ts
Error:(5,10) TS2440: Import declaration conflicts with local declaration of 'PluginConfig'.
Error:(5,24) TS2440: Import declaration conflicts with local declaration of 'ProtractorPlugin'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/aria-describer/aria-describer.d.ts
Error:(8,53) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts
Error:(9,71) TS2307: Cannot find module '@angular/core'.
Error:(10,28) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/focus-trap/focus-trap.d.ts
Error:(8,74) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/key-manager/list-key-manager.d.ts
Error:(8,27) TS2307: Cannot find module '@angular/core'.
Error:(9,25) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/live-announcer/live-announcer-tokens.d.ts
Error:(8,32) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/cdk/a11y/typings/live-announcer/live-announcer.d.ts
Error:(9,57) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/cdk/observers/typings/observe-content.d.ts
Error:(8,79) TS2307: Cannot find module '@angular/core'.
Error:(9,28) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/material/typings/core/common-behaviors/color.d.ts
Error:(9,28) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/common-behaviors/common-module.d.ts
Error:(8,32) TS2307: Cannot find module '@angular/core'.
Error:(9,30) TS2307: Cannot find module '@angular/platform-browser'.
/myDevFolder/node_modules/@angular/material/typings/core/common-behaviors/error-state.d.ts
Error:(8,55) TS2307: Cannot find module '@angular/forms'.
Error:(9,25) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/material/typings/core/common-behaviors/initialized.d.ts
Error:(8,28) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/material/typings/core/datetime/date-adapter.d.ts
Error:(8,37) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/material/typings/core/datetime/date-formats.d.ts
Error:(8,32) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/error/error-options.d.ts
Error:(8,57) TS2307: Cannot find module '@angular/forms'.
/myDevFolder/node_modules/@angular/material/typings/core/gestures/gesture-config.d.ts
Error:(8,37) TS2307: Cannot find module '@angular/platform-browser'.
/myDevFolder/node_modules/@angular/material/typings/core/label/label-options.d.ts
Error:(8,32) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/line/line.d.ts
Error:(8,39) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/option/option.d.ts
Error:(8,117) TS2307: Cannot find module '@angular/core'.
Error:(10,25) TS2307: Cannot find module 'rxjs'.
/myDevFolder/node_modules/@angular/material/typings/core/ripple/ripple-renderer.d.ts
Error:(8,36) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/ripple/ripple.d.ts
Error:(9,71) TS2307: Cannot find module '@angular/core'.
/myDevFolder/node_modules/@angular/material/typings/core/version.d.ts
Error:(8,25) TS2307: Cannot find module '@angular/core'.

更多信息

我重新进行了ng更新的迁移,这次出现了一个错误

❯ Undecorated classes with DI migration.
  As of Angular 9,it is no longer supported to use Angular DI on a class that does not have an Angular decorator.
  Read more about this here: https://v9.angular.io/guide/migration-undecorated-classes
Failed to read JSON file /myDevFolder/dev/node_modules/@angular/material/typings/core/index.Metadata.json
    
    This migration uses the Angular compiler internally and therefore projects that no longer build successfully after the update cannot run the migration. Please ensure there are no AOT compilation errors and rerun the migration. The following project Failed: src/tsconfig.app.json
    
    Error: Path "/../node_modules/@angular/material/typings/core/index.Metadata.json" is invalid.
    
    Could not migrate all undecorated classes that use dependency
    injection. Some project targets Could not be analyzed due to
    TypeScript program failures.

解决方法

我在这里找到了问题的解决方案:Missing material dependencies after upgrade to Angular 9。也许它可以帮助你。 基本上是:

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...