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

Posted Binge - 和时间做朋友

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 所依赖的组件版本

以上是关于npm install 报错:verbose stack Error: unable to resolve dependency tree的主要内容,如果未能解决你的问题,请参考以下文章

npm install报错

npm install报错node-sass

npm publish报错403 Forbidden - PUT http://XXX - forbidden;http fetch PUT 403 http://XXX ; verbose stac

npm install 报错(npm ERR! errno 1)

npm install 报错 --ignore-scripts

npm install报错Error: ENOENT