npm install 报错:verbose stack Error: unable to resolve dependency tree

错误描述

复制代码
> npm install
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: admin00@0.0.0
npm ERR! Found: vite@2.1.3
npm ERR! node_modules/vite
npm ERR!   dev vite@"2.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! node_modules/@vitejs/plugin-vue
npm ERR!   dev @vitejs/plugin-vue@"2.3.3" 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! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-02-01T01_39_38_660Z-debug-0.log

原因分析

经排查

  1. 发现有组件package.json中有peer dependency,指明了angular 7.x 的版本,与当前项目依赖的angular 8.x的版本不兼容,导致编译报错

  2. 另外,原先使用npm 6.x install是没有问题的,是因为npm 7.x 对peer dependency的兼容性要求更高,所以报错。

解决方法

方法1:
添加 --force 或者 --legacy-peer-deps
复制代码
>npm install --force
>npm  install --legacy-peer-deps
方法2:

修改问题组件的依赖定义 package.json,修正 peer-dependency 所依赖的组件版本

posted @   Binge-和时间做朋友  阅读(1384)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示