vue安装less-loader由于版本过高的问题
vue 2022-01-05 08:59:09

看一下正常的安装报错:

  antdv3 git:(master) npm install less less-loader --save

npm ERR! code ERESOLVE

npm ERR! ERESOLVE unable to resolve dependency tree

npm ERR! 

npm ERR! Found: webpack@4.46.0

npm ERR! node_modules/webpack

npm ERR!   peer webpack@"^4.0.0" from @intervolga/optimize-cssnano-plugin@1.0.6

npm ERR!   node_modules/@intervolga/optimize-cssnano-plugin

npm ERR!     @intervolga/optimize-cssnano-plugin@"^1.0.5" from @vue/cli-service@4.5.15

npm ERR!     node_modules/@vue/cli-service

npm ERR!       peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.15

npm ERR!       node_modules/@vue/cli-plugin-babel

npm ERR!         dev @vue/cli-plugin-babel@"~4.5.0" from the root project

npm ERR!       5 more (@vue/cli-plugin-eslint, @vue/cli-plugin-pwa, ...)

npm ERR!   peer webpack@"^4.0.0 || ^5.0.0" from @soda/friendly-errors-webpack-plugin@1.8.1

npm ERR!   node_modules/@soda/friendly-errors-webpack-plugin

npm ERR!     @soda/friendly-errors-webpack-plugin@"^1.7.1" from @vue/cli-service@4.5.15

npm ERR!     node_modules/@vue/cli-service

npm ERR!       peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.15

npm ERR!       node_modules/@vue/cli-plugin-babel

npm ERR!         dev @vue/cli-plugin-babel@"~4.5.0" from the root project

npm ERR!       5 more (@vue/cli-plugin-eslint, @vue/cli-plugin-pwa, ...)

npm ERR!   21 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)

npm ERR! 

npm ERR! Could not resolve dependency:

npm ERR! less-loader@"*" from the root project

npm ERR! 

npm ERR! Conflicting peer dependency: webpack@5.65.0

npm ERR! node_modules/webpack

npm ERR!   peer webpack@"^5.0.0" from less-loader@10.2.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 /Users/yoyo/.npm/eresolve-report.txt for a full report.

 

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/yoyo/.npm/_logs/2022-01-05T00_39_51_254Z-debug.log

 

解决方案:

C/C++ Code复制内容到剪贴板
  1. ## 安装到dev环境,在devDependencies下面,正式环境并不需要  
  2. npm i less --save-dev  

 

先把less安装最新版本,然后指定版本安装less-loader:

C/C++ Code复制内容到剪贴板
  1. npm i less-loader@7 -D  

 

 

yarn命令:

C/C++ Code复制内容到剪贴板
  1. ## 安装  
  2. yarn add less -D  
  3.   
  4. ## 卸载  
  5. yarn remove less  

 

 

 

 

本文来自于:http://www.yoyo88.cn/study/vue/611.html

Powered by yoyo苏ICP备15045725号