gpt4 book ai didi

angular - 目标入口点 "@angular/cdk/platform"缺少依赖项

转载 作者:行者123 更新时间:2023-12-02 19:16:49 28 4
gpt4 key购买 nike

我有一个版本 8 的 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、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, 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.

最佳答案

我在这里找到了问题的解决方案: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

关于angular - 目标入口点 "@angular/cdk/platform"缺少依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63599070/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com