一般咱们需要下载依赖时都是需要使用npm install
来下载
但是有时候是下载不了的:
报错:
code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/compiler-sfc@3.1.5
npm ERR! Found: vue@3.0.2
npm ERR! node_modules/vue
npm ERR! vue@"^3.0.2" from the root project
npm ERR! peerOptional vue@"^2 || ^3.0.0-0" from @vue/babel-preset-app@4.5.13
npm ERR! node_modules/@vue/babel-preset-app
npm ERR! @vue/babel-preset-app@"^4.5.13" from @vue/cli-plugin-babel@4.5.13
npm ERR! node_modules/@vue/cli-plugin-babel
npm ERR! dev @vue/cli-plugin-babel@"~4.5.0" from the root project
npm ERR! @vue/babel-preset-app@"^4.1.2" from @vuepress/core@1.9.7
npm ERR! node_modules/@vuepress/core
npm ERR! @vuepress/core@"1.9.7" from vuepress@1.9.7
npm ERR! node_modules/vuepress
npm ERR! peer vuepress@"^1.0.0" from @vssue/vuepress-plugin-vssue@1.4.8
npm ERR! node_modules/@vssue/vuepress-plugin-vssue
npm ERR! 2 more (vue-cli-plugin-cesium, vuepress-plugin-feed)
npm ERR! 4 more (vue-demi, vue-property-decorator, vue-router, vuex)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"3.1.5" from @vue/compiler-sfc@3.1.5
npm ERR! node_modules/@vue/compiler-sfc
npm ERR! dev @vue/compiler-sfc@"^3.0.0" from the root project
npm ERR! peerOptional @vue/compiler-sfc@"^3.0.0-beta.14" from @vue/cli-service@4.5.13
npm ERR! node_modules/@vue/cli-service
npm ERR! dev @vue/cli-service@"~4.5.0" from the root project
npm ERR! 4 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
npm ERR!
npm ERR! Conflicting peer dependency: vue@3.1.5
npm ERR! node_modules/vue
npm ERR! peer vue@"3.1.5" from @vue/compiler-sfc@3.1.5
npm ERR! node_modules/@vue/compiler-sfc
npm ERR! dev @vue/compiler-sfc@"^3.0.0" from the root project
npm ERR! peerOptional @vue/compiler-sfc@"^3.0.0-beta.14" from @vue/cli-service@4.5.13
npm ERR! node_modules/@vue/cli-service
npm ERR! dev @vue/cli-service@"~4.5.0" from the root project
npm ERR! 4 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
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 C:\Users\CCL\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\CCL\AppData\Local\npm-cache\_logs\2022-07-04T08_40_03_525Z-debug-0.log
解决方案 1:降级节点版本
您有依赖关系冲突(不正确且可能损坏的依赖关系),因为它说,因此请尝试使用 或 运行命令,如果它没有生效,临时解决方案是使用节点的先前版本 (降级节点版本),因为它有时会导致发生此类错误。–force–legacy-peer-deps
npm install --save --force --legacy-peer-deps
解决方案 2:使用 – 旧版对等部门 命令:
npm install --save --legacy-peer-deps
解决方案 3:npm 配置集旧版-对等-对等值设置为 true
npm config set legacy-peer-deps true
解决方案 4:尝试 npm 缓存清理 – 强制
node modules package-lock.jsonnpm installnpm cache clean --force
我报错是因为我在下面这两个文件夹里面改了配置所以报错
我都解决方法是在你需要下载依赖的那个项目用cmd打开然后用cnpm -install
下载
以为我很菜只能用最笨的方法了所以各位大佬有啥比较好的方法可以指点一二!!!感谢(抱拳)