安装less-loader时报错

npm install --save less less-loader@5  

在输入上述命令安装less-loader@5时报错如下:

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/webpack
npm ERR!   webpack@"^5.74.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^2.0.0 || ^3.0.0 || ^4.0.0" from [email protected]
npm ERR! node_modules/less-loader
npm ERR!   less-loader@"5" 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\86173\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\86173\AppData\Local\npm-cache\_logs\2022-11-07T14_30_47_517Z-debug-0.log

原因:npm版本太高

解决方法:安装低版本的

npm install [email protected] -g

猜你喜欢

转载自blog.csdn.net/m0_70619994/article/details/127741143