Webpack multi version incompatibility error

NPM run build packaging source code is incompatible with multiple versions of webpack, and an error is reported

Then use NPM run build to package the source code, and there is a webpack error, and then the prompt message of NPM audit fix is as follows

[email protected]:~/Downloads/dingtalk$ npm audit fix
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer [email protected]"4.x.x || 5.x.x" from @webpack-cli/[email protected]
npm ERR!   node_modules/@webpack-cli/configtest
npm ERR!     @webpack-cli/[email protected]"^1.1.0" from [email protected]
npm ERR!     node_modules/webpack-cli
npm ERR!       dev [email protected]"^4.9.1" from the root project
npm ERR!       3 more (@webpack-cli/configtest, @webpack-cli/info, @webpack-cli/serve)
npm ERR!   peer [email protected]">=2" from [email protected]
npm ERR!   node_modules/babel-loader
npm ERR!     dev [email protected]"^8.1.0" from the root project
npm ERR!   13 more (clean-webpack-plugin, eslint-loader, file-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer [email protected]"^4.27.0 || ^5.0.0" from [email protected]
npm ERR! node_modules/css-loader
npm ERR!   dev [email protected]"^4.2.1" from the root project
npm ERR!   peer [email protected]"*" from [email protected]
npm ERR!   node_modules/vue-loader
npm ERR!     dev [email protected]"^15.9.3" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer [email protected]"^4.27.0 || ^5.0.0" from [email protected]
npm ERR!   node_modules/css-loader
npm ERR!     dev [email protected]"^4.2.1" from the root project
npm ERR!     peer [email protected]"*" from [email protected]
npm ERR!     node_modules/vue-loader
npm ERR!       dev [email protected]"^15.9.3" 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 /home/su/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/su/.npm/_logs/2021-11-01T01_35_04_547Z-debug.log

My approach is to uninstall the current webpack and then reassign a global version.

sudo npm uninstall webpack
sudo npm install [email protected] -g

Read More: