Laravel8 npm run dev 输出:ERESOLVE 无法解析依赖树

Mai*_*rey 1 npm laravel

目标

避免出现错误消息。当我运行命令时,我收到以下错误消息npm run dev

npm notice 
npm notice New major version of npm available! 7.6.1 -> 8.1.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4
npm notice Run npm install -g npm@8.1.4 to update!
npm notice 

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: acorn@7.4.1
npm ERR! node_modules/acorn
npm ERR!   acorn@"^7.0.0" from acorn-node@1.8.2
npm ERR!   node_modules/acorn-node
npm ERR!     acorn-node@"^1.6.1" from detective@5.2.0
npm ERR!     node_modules/detective
npm ERR!       detective@"^5.2.0" from tailwindcss@2.2.19
npm ERR!       node_modules/tailwindcss
npm ERR!         dev tailwindcss@"^2.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional acorn@"^8.5.0" from terser@5.10.0
npm ERR! node_modules/terser
npm ERR!   terser@"^5.9.0" from laravel-mix@6.0.39
npm ERR!   node_modules/laravel-mix
npm ERR!     dev laravel-mix@"^6.0.6" from the root project
npm ERR!   terser@"^5.7.2" from terser-webpack-plugin@5.2.5
npm ERR!   node_modules/terser-webpack-plugin
npm ERR!     terser-webpack-plugin@"^5.2.4" from laravel-mix@6.0.39
npm ERR!     node_modules/laravel-mix
npm ERR!       dev laravel-mix@"^6.0.6" from the root project
npm ERR!     1 more (webpack)
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/ml/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ml/.npm/_logs/2021-12-02T07_41_55_149Z-debug.log

Run Code Online (Sandbox Code Playgroud)

快速解决方案:

我可以使用以下命令避免出现问题/错误消息: npm install --legacy-peer-deps

输出:

npm notice 
npm notice New major version of npm available! 7.6.1 -> 8.1.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4
npm notice Run npm install -g npm@8.1.4 to update!
npm notice 

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: acorn@7.4.1
npm ERR! node_modules/acorn
npm ERR!   acorn@"^7.0.0" from acorn-node@1.8.2
npm ERR!   node_modules/acorn-node
npm ERR!     acorn-node@"^1.6.1" from detective@5.2.0
npm ERR!     node_modules/detective
npm ERR!       detective@"^5.2.0" from tailwindcss@2.2.19
npm ERR!       node_modules/tailwindcss
npm ERR!         dev tailwindcss@"^2.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional acorn@"^8.5.0" from terser@5.10.0
npm ERR! node_modules/terser
npm ERR!   terser@"^5.9.0" from laravel-mix@6.0.39
npm ERR!   node_modules/laravel-mix
npm ERR!     dev laravel-mix@"^6.0.6" from the root project
npm ERR!   terser@"^5.7.2" from terser-webpack-plugin@5.2.5
npm ERR!   node_modules/terser-webpack-plugin
npm ERR!     terser-webpack-plugin@"^5.2.4" from laravel-mix@6.0.39
npm ERR!     node_modules/laravel-mix
npm ERR!       dev laravel-mix@"^6.0.6" from the root project
npm ERR!     1 more (webpack)
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/ml/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ml/.npm/_logs/2021-12-02T07_41_55_149Z-debug.log

Run Code Online (Sandbox Code Playgroud)

问题

我需要做什么才能npm install再次运行而不收到错误消息?

sha*_*cat 5

我也有同样的问题。我已经用这条线修复了它

npm 我橡子 --dev

然后再次运行

npm install && 安装运行开发