npm下载报错

最近使用npm安装一些包时经常遇到遇到的一个问题,记录一下。

报错:

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: @vue/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint-plugin-vue
npm ERR!   dev eslint-plugin-vue@"^8.0.3" from the root project   
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/[email protected]
npm ERR! node_modules/@vue/eslint-config-standard
npm ERR!   dev @vue/eslint-config-standard@"^6.1.0" from the root 
project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]    
npm ERR! node_modules/eslint-plugin-vue
npm ERR!   peer eslint-plugin-vue@"^7.0.0" from @vue/[email protected]
npm ERR!   node_modules/@vue/eslint-config-standard
npm ERR!     dev @vue/eslint-config-standard@"^6.1.0" from the root project
npm ERR!
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 C:\Users\abing\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\abing\AppData\Local\npm-cache\_logs\2022-08-30T07_39_24_341Z-debug-0.log

解决:

--legacy-peer-deps

在安装命令后加上 --legacy-peer-deps

原因:

在NPM v7中,现在默认安装peerDependencies

在很多情况下,这会导致版本冲突,从而中断安装过程。

--legacy-peer-deps标志是在v7中引入的,目的是绕过peerDependency自动安装;它告诉 NPM 忽略项目中引入的各个modules之间的相同modules但不同版本的问题并继续安装,保证各个引入的依赖之间对自身所使用的不同版本modules共存。

参考:npm下载报错npm ERR code ERESOLVE_Aaron Con的博客-CSDN博客_npm 下载报错

--legacy-peer-deps 作用_longfei815的博客-CSDN博客_legacy-peer-deps

你可能感兴趣的:(vue,前端,npm,vue.js,前端)