牛叔叔 的笔记

好好学习

2023-07-21 11:29

本地部署安装Ruoyi前端时报错的处理

牛叔叔

WEB前端

(1408)

(0)

收藏

错误如下:
npm install --registry=https://registry.npm.taobao.org
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ruoyi@3.6.1
npm ERR! Found: webpack@5.88.2
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.0.0 || ^5.0.0" from html-webpack-plugin@4.5.2
npm ERR!   node_modules/html-webpack-plugin
npm ERR!     peer html-webpack-plugin@"^3.0.0 || ^4.0.0" from script-ext-html-webpack-plugin@2.1.5
npm ERR!     node_modules/script-ext-html-webpack-plugin
npm ERR!       dev script-ext-html-webpack-plugin@"2.1.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" from script-ext-html-webpack-plugin@2.1.5
npm ERR! node_modules/script-ext-html-webpack-plugin
npm ERR!   dev script-ext-html-webpack-plugin@"2.1.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\Administrator\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\Administrator\AppData\Local\npm-cache\_logs\2023-07-21T03_23_14_918Z-debug.log



这个错误是由于npm在解析依赖树时遇到了冲突导致的。根据错误日志显示,你的项目需要安装webpack,并且要求 webpack@"^4.0.0 || ^5.0.0" ,而在安装html-webpack-plugin@4.5.2时,它需要 webpack@"^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0"。


解决这个问题你有以下几个选择:


1. 使用--force参数重试安装命令,即运行`npm install --registry=https://registry.npm.taobao.org --force`,这将强制安装并忽略依赖冲突。但这可能会导致项目中的某些依赖关系出现问题,所以需要谨慎使用。


2. 使用--legacy-peer-deps参数重试安装命令,即运行`npm install --registry=https://registry.npm.taobao.org --legacy-peer-deps`。这将使用旧版依赖解析算法,以兼容旧版本的npm,可能能够解决依赖冲突问题。


3. 手动调整你的项目依赖关系,使得html-webpack-plugin和webpack的版本能够兼容。你可以尝试在package.json文件中更新html-webpack-plugin和webpack的版本范围,或者查找其他兼容的版本。


无论你选择哪种解决方案,请确保备份项目文件并注意可能引入的潜在问题。


0条评论

点击登录参与评论