簡體   English   中英

無法在 VueCLI3 項目中安裝 less-loader

[英]Can't install less-loader in VueCLI3 project

我的項目的某些頁面使用less來渲染,所以我運行npm命令安裝less和less-loader但發現less可以成功安裝,由於未知原因,less-loader一直無法安裝並拋出如下錯誤:

PS E:\myprogramming\tutorial\frontEND\eduResourceCode\Vue教程\復習\Vue腳手架CLI3\vuexdemo_> npm i less-loader
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.13
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.13
npm ERR!       node_modules/@vue/cli-plugin-babel
npm ERR!         dev @vue/cli-plugin-babel@"~4.5.0" from the root project
npm ERR!       4 more (@vue/cli-plugin-eslint, @vue/cli-plugin-router, ...)
npm ERR!   peer webpack@"^4.0.0 || ^5.0.0" from @soda/friendly-errors-webpack-plugin@1.8.0
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.13
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.13
npm ERR!       node_modules/@vue/cli-plugin-babel
npm ERR!         dev @vue/cli-plugin-babel@"~4.5.0" from the root project
npm ERR!       4 more (@vue/cli-plugin-eslint, @vue/cli-plugin-router, ...)
npm ERR!   18 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.38.1
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^5.0.0" from less-loader@9.1.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\hw\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\hw\AppData\Local\npm-cache\_logs\2021-06-13T12_28_33_753Z-debug.log

但是我的開發服務器沒有less-loader就無法運行,我嘗試了很多方法,比如重新安裝兩個依賴項,使用vue-cil下載同名插件,或者將其他less-loader標簽粘貼到我的package.json不行。

我找到了一個可能但奇怪的原因是我的 node_modules 沒有 less-loader 文件夾? 現在我該如何解決? 在此處輸入圖像描述

我通過使用 css-prodecessor 合並我的項目,它解決了我的問題。但我仍然感到困惑。 我不喜歡通過合並來解決問題,因為它會破壞我已經完成的一些文件。 如果在我的項目建成后我可以擁有 less-loader 那就更好了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM