电脑npm install报错; 报错日志如下:

npm ERR! code ERESOLVEnpm ERR! ERESOLVE could not resolvenpm ERR!npm ERR! While resolving: @vue/eslint-config-standard@6.1.0npm ERR! Found: eslint-plugin-vue@8.7.1npm ERR! node_modules/eslint-plugin-vuenpm ERR! dev eslint-plugin-vue@"^8.0.3" from the root projectnpm ERR!npm ERR! Could not resolve dependency:npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0npm ERR! node_modules/@vue/eslint-config-standardnpm ERR! dev @vue/eslint-config-standard@"^6.1.0" from the root projectnpm ERR!npm ERR! node_modules/eslint-plugin-vuenpm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0npm ERR! node_modules/@vue/eslint-config-standardnpm ERR! dev @vue/eslint-config-standard@"^6.1.0" from the root projectnpm ERR!npm ERR! Fix the upstream dependency conflict, or retrynpm ERR! this command with --force, or --legacy-peer-depsnpm ERR! to accept an incorrect (and potentially broken) dependency resolution.npm ERR!npm ERR! See C:\Users\AB123\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\AB123\AppData\Local\npm-cache\_logs\2023-01-24T03_08_49_805Z-debug-0.log

上述报错日志中有个关键字眼:this command with --force, or --legacy-peer-deps

npm ERR! Fix the upstream dependency conflict, or retrynpm ERR! this command with --force, or --legacy-peer-depsnpm ERR! to accept an incorrect (and potentially broken) dependency resolution.

那么npm:何时使用--force--legacy-peer-deps
--force 会无视冲突,并强制获取远端npm库资源,即使本地有资源也会覆盖掉
--legacy-peer-deps:安装时忽略所有peerDependencies,忽视依赖冲突,已有的依赖不会覆盖,。
建议用--legacy-peer-deps 比较保险一点,反正我用了就安装成功了;


比如原本的命令为 npm i vuex-persistedstate 。改为npm i vuex-persistedstate –legacy-peer-deps即可。其余同样如此