解决npm安装依赖的冲突紧急解决办法

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: less-loader@5.0.0
npm ERR! Found: less@4.1.2
npm ERR! node_modules/less
npm ERR!   dev less@"^4.1.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer less@"^2.3.1 || ^3.0.0" from less-loader@5.0.0
npm ERR! node_modules/less-loader
npm ERR!   less-loader@"^5.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: less@3.13.1
npm ERR! node_modules/less
npm ERR!   peer less@"^2.3.1 || ^3.0.0" from less-loader@5.0.0
npm ERR!   node_modules/less-loader
npm ERR!     less-loader@"^5.0.0" 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 D:\node\node_cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\node\node_cache\_logs\2022-09-26T01_56_16_788Z-debug-0.log

安装中报错,可以在后面加–legacy-peer-deps

NPM v7中,现在默认安装peerDependencies。

在很多情况下,这会导致版本冲突,从而中断安装过程。

--legacy-peer-deps标志是在v7中引入的,目的是绕过peerDependency自动安装;它告诉 NPM 忽略项目中引入的各个modules之间的相同modules但不同版本的问题并继续安装,保证各个引入的依赖之间对自身所使用的不同版本modules共存。

你可能感兴趣的:(vue,日常问题,npm,javascript,前端)