npm install
F:\tewst1111>npm i
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: uglifyjs-webpack-plugin@2.2.0
npm ERR! Found: webpack@5.90.2
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^5.0.0" from css-loader@6.7.2
npm ERR! node_modules/css-loader
npm ERR! dev css-loader@"^6.7.1" from the root project
npm ERR! peer webpack@"^4.0.0 || ^5.0.0" from file-loader@6.2.0
npm ERR! node_modules/file-loader
npm ERR! peerOptional file-loader@"*" from url-loader@4.1.1
npm ERR! node_modules/url-loader
npm ERR! dev url-loader@"^4.1.1" from the root project
npm ERR! dev file-loader@"^6.2.0" from the root project
npm ERR! 3 more (html-webpack-plugin, style-loader, url-loader)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from uglifyjs-webpack-plugin@2.2.0
npm ERR! node_modules/uglifyjs-webpack-plugin
npm ERR! dev uglifyjs-webpack-plugin@"^2.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@4.47.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^4.0.0" from uglifyjs-webpack-plugin@2.2.0
npm ERR! node_modules/uglifyjs-webpack-plugin
npm ERR! dev uglifyjs-webpack-plugin@"^2.2.0" 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!
npm ERR! For a full report see:
npm ERR! D:\nodejs\node_cache\_logs\2024-02-19T09_16_04_397Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! D:\nodejs\node_cache\_logs\2024-02-19T09_16_04_397Z-debug-0.log
这个错误是由于npm在解析依赖关系时发生了冲突导致的。根据错误信息显示,uglifyjs-webpack-plugin@2.2.0 需要 webpack@^4.0.0 作为 peer dependency,但是项目中已经安装了 webpack@5.90.2,这就导致了冲突。
解决这个问题的方法之一是尝试使用`--force`或者`--legacy-peer-deps`选项来强制接受不完全匹配的依赖关系解析。可以尝试运行以下命令来安装 :
npm install --legacy-peer-deps
这将会尝试使用旧的方式来解决依赖关系,可能会解决这个问题。如果还是无法解决,可以尝试更新或者降级uglifyjs-webpack-plugin和相关的依赖版本,以使它们与webpack@5兼容。
npm清除缓存
npm cache clean --force