报错npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree报错解决办法

报错npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree报错解决办法

报错如下:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: webpackdemo@1.0.0
npm ERR! Found: webpack@5.73.0
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^5.73.0" from the root project
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from optimize-css-assets-webpack-plugin@6.0.1
npm ERR! node_modules/optimize-css-assets-webpack-plugin
npm ERR!   dev optimize-css-assets-webpack-plugin@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this ***mand with --force, or --legacy-peer-deps
npm ERR! to a***ept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! for a full report.

解决:

1. 查看版本

//  win+r 命令行输入以下代码查看版本
npm -v
node -v

2.降低npm版本

因为高版本的比低版本的严格,所以会报错

//  win+r 命令行输入以下代码
npm install npm@6.14.10 -g

3.项目中删除文件

将项目中的node-modules文件夹package-lock.json文件删除。

4.重新在项目中引入需要的配置

项目根目录下命令行:npm install
即可自动生成 步骤3 中删除的两个文件

5. 参考博客

https://blog.csdn.***/m0_51969330/article/details/119186416
https://blog.csdn.***/m0_67391521/article/details/123425411

转载请说明出处内容投诉
CSS教程_站长资源网 » 报错npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree报错解决办法

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买