我从v13升级了Angular到第十四节
ng update @angular/core@14 @angular/cli@14
ng update @angular/material@14
升级后出现错误:
./node_modules/@angular/material/fesm2015/dialog.mjs:1:0-93 - Error: Module not found: Error: Package path ./dialog is not exported from package D:projectNamenode_modules@angularcdk (see exports field in D:projectNamenode_modules@angularcdkpackage.json)
Error: node_modules/@angular/material/dialog/index.d.ts:3:36 - error TS2307: Cannot find module '@angular/cdk/dialog' or its corresponding type declarations.
3 import { CdkDialogContainer } from '@angular/cdk/dialog';
这是我的package.json:
"dependencies": {
"@angular/animations": "^14.0.1",
"@angular/cdk": "^14.0.1",
"@angular/common": "^14.0.1",
"@angular/compiler": "^14.0.1",
"@angular/core": "^14.0.1",
"@angular/forms": "^14.0.1",
"@angular/material": "^14.0.1",
"@angular/platform-browser": "^14.0.1",
"@angular/platform-browser-dynamic": "^14.0.1",
我不知道我做错了什么,谢谢你的帮助。
1。确保你已经安装了angular/cdk。如果您还没有安装,请运行以下命令:
npm i @angular/cd
2。确保您已经导入了CdkDialogContainer。如果您还没有导入,请导入以下代码,其中您的材质模块进口的。
import { CdkDialogContainer } from '@angular/cdk/dialog';
我认为你需要重新安装你的node_modules,试试这些命令:
rm -rf node_modules
rm -f package-lock.json
npm cache clean——force
npm install——forcenpm i @angular/cdk为我工作,当我遵循这个例子https://material.angular.io/cdk/layout/overview