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

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

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

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

@angular/core
@angular/common

这些是我 package.json 中的 angular 包:

        "@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、程序包-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, 32) TS2307: Cannot find module '@angular/core'.
Error:(9, 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, 32) TS2307: Cannot find module '@angular/core'.
Error:(9, 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 update 的迁移,这次出现了错误:

❯ 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.

我在这里找到了问题的解决方案:。也许它可以帮助你。 基本上是:

  • 删除 node_modules 文件夹。
  • 删除包-lock.json文件。
  • 运行 npm 缓存清理 --force
  • 运行 npm install --save @angular/material @angular/cdk
  • 运行 npm 安装