先说解决问题的方法:在npm i less-loader 后面加上–legacy-peer-deps
如下:
npm i less-loader --legacy-peer-deps
然后我们来看我遇到的问题:
我引入less时无任何报错,但是在引入less解析器时便报出code ERESOLVE等错误
npm i less-loader
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: cabinet@1.0.0
npm ERR! Found: webpack@3.12.0
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from less-loader@11.0.0
npm ERR! node_modules/less-loader
npm ERR! less-loader@"*" 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\48078\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\48078\AppData\Local\npm-cache\_logs\2022-05-22T16_44_50_694Z-debug-0.log