首页 > 其他分享 >npm install 报错:verbose stack Error: unable to resolve dependency tree

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

时间:2023-02-01 10:01:58浏览次数:52  
标签:npm resolve old ERR -- dependency 报错 install

错误描述

> 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: [email protected]
npm ERR! Found: [email protected]
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,resolve,old,ERR,--,dependency,报错,install
From: https://www.cnblogs.com/binbingg/p/17081606.html

相关文章