我试着在终端中运行这个命令:
npm i moment @angular/material-moment-adapter.我有错误:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: xxxxxxxx-xx@0.0.0 npm ERR! Found: @angular/core@10.2.5
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0" from the root project
npm ERR! npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^14.0.0 || ^15.0.0" from @angular/material-moment-adapter@14.1.1
npm ERR! node_modules/@angular/material-moment-adapter
npm ERR! @angular/material-moment-adapter@"*" from the root project
npm ERR! npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\xxx\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\xxxx\AppData\Local\npm-cache\_logs\2022-08-11T06_40_07_646Z-debug-0.log我试着运行npm install和npm i moment,但没有工作。
(其他“重复问题”并不相同)
这是json包:
{“名称”:“证书-盲”、“版本”:"0.0.0“、”脚本“:{ "ng”:"ng“、”启动“:"ng服务”、“构建”:"ng构建“、”测试“:"ng测试”、" lint“:"ng lint”、" e2e“:”ng e2e“、”ng e2e“、”format“-写”src//*“。{ts、html、scss、"!src//migrate/**/.“}、”私有“:真、”依赖关系“:{”@角/动画“:”~10.1.6“、”@角/cdk“:"^10.2.7”、“@角/公共”:“~10.1.6”、“@角/编译器”:"~10.1.6",“@角形/核心”:"^6.0.0 \x{e76f}\x{e76f}/形式:"~10.1.6",“@角/形”:"~10.1.6",“@角/形”:"~10.1.6",“@角/形”:"^10.2.7",“@角/平台-浏览器-浏览器-动态”:"~10.1.6",“@角/路由器”:“~10.1.6”,“@角/路由器”:“~10.1.6”,"@binssoft/ngx-captcha":"^1.0.0“、”@type/lodash“:"^4.14.162”、"cors":"^2.8.5“、”文件保护程序“:"^2.0.5”、“扁平”:"^3.2.4“、”住所“:"^4.17.20”、“mat-file-上载”:"^11.1.2“、"ng-recaptcha":"^8.0.1”、“ngx-引导”:"^6.2.0“、”更漂亮“:"^2.1.2”、"rxjs":"~6.6.0“、"tslib":"^2.0.0”、"zone.js":"~0.10.2“}、"devDependencies":{”@angular/build-devDependencies“:{ "~0.1001.7”、“@角/cli”:"^10.2.3",“@角/编译器-cli”:"~10.1.6“、”@类型/文件保护程序“:"^2.0.1”、“@类型/茉莉花”:"~3.5.0“、”@type/jasminewd2 2“:"~2.0.3”、“@类型/节点”:"^12.11.1“、"codelyzer":"^6.0.0”、“茉莉-核心”:"~3.6.0“、“茉莉花-规范-记者”:"~5.0.0",“量角器”:"~7.0.0",“ts-节点”:"~8.3.0","tslint":"~6.1.0",“打字本”:"~4.0.2“},"peerDependencies":{”@角形/核心“:{ "^6.0.0 \x ^7.0.0 \x^ ^8.0.0 \x^8.0.0\x^10.0.0}
。
发布于 2022-08-14 12:37:24
为什么得到错误
您正在尝试将最新版本的14.1.1( @angular/material-moment-adapter )安装到主要版本10上的一个major项目中。这会导致依赖冲突,因为不同的角度包相互依赖,并且通常需要相同的主版本。
您可以从以下错误消息中读取此信息:
从“角度/材料-转接器@14.1.1”发出的对等点“角形/核心”^14.0.0 x\^15.0.0
它说,@angular/material-moment-adapter希望@angular/core在14.x.x或15.x.x版本中。
你能做什么:
就你的情况而言,我认为有两种可能的方法:
@angular/material-moment-adapter的旧版本:npm i@角/材料-力矩-适配器@10矩
14 (一步一步)。有关帮助,请参见他们的更新指南。Side notes
@angular/core依赖项在package.json的依赖项部分看起来很奇怪:“@角质/核心”:"^6.0.0 \x\x{e76f}\\{e76f}\x{e76f}{##**$}}#^10.
使用此设置,基本上允许6.0.0和最新的10种版本之间的任何版本。但是,10.x.x以外的任何其他版本都会导致与其他依赖项的冲突。因此,我建议在这里使用不同的版本规范,比如为@angular/common等指定的版本规范(= ~10.1.6)。
@angular/core作为对等依赖项。这意味着,任何安装您的包的人都需要在这里列出的任何版本中安装@angular/core:“@转角/核心”:"^6.0.0 \x\x{e76f}\x{e76f}\x{e76f}\
如果您的工作区不包含其他库或应用程序应该使用的库,那么您可能希望删除这个peerDependencies条目。
https://stackoverflow.com/questions/73316422
复制相似问题