NPM INSTALL 的时候提示“ERESOLVE could not resolve”
我们通常使用 npm install
来为 vue项目 导入组件库,但是有时候会莫名报错,如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/cli-plugin-typescript@4.5.15
npm ERR! Found: @vue/cli-service@5.0.8
npm ERR! node_modules/@vue/cli-service
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0 || ^5.0.0-0" from @vue/cli-plugin-babel@5.0.8
npm ERR! node_modules/@vue/cli-plugin-babel
npm ERR! dev @vue/cli-plugin-babel@"~5.0.0" from the root project
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0 || ^5.0.0-0" from @vue/cli-plugin-eslint@5.0.8
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"~5.0.0" from the root project
npm ERR! 3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-typescript@4.5.15
npm ERR! node_modules/@vue/cli-plugin-typescript
npm ERR! dev @vue/cli-plugin-typescript@"^4.5.15" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @vue/cli-service@4.5.19
npm ERR! node_modules/@vue/cli-service
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-typescript@4.5.15
npm ERR! node_modules/@vue/cli-plugin-typescript
npm ERR! dev @vue/cli-plugin-typescript@"^4.5.15" 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 D:\Pro\nodejs\node_cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Pro\nodejs\node_cache\_logs\2022-10-31T14_56_56_793Z-debug-0.log
这是因为组件库所使用的依赖库版本和本地安装版本不一致导致!简言之依赖冲突。
解决办法也很简单,可以使用 --legacy-peer-deps
忽略冲突来安装。语法如下:
npm install [...] --legacy-peer-deps
本文来自博客园,作者:七月的枫丶 ,部分内容摘自互联网,转载请注明原文链接:https://www.cnblogs.com/easybook/p/16846256.html