我们通常使用 npm install
来为 vue项目 导入组件库,但是有时候会莫名报错,如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/[email protected]
npm ERR! Found: @vue/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
npm ERR! node_modules/@vue/cli-service
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/[email protected]
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
标签:NPM,npm,resolve,cli,ERR,plugin,could,vue,peer From: https://www.cnblogs.com/esaybook/p/16846256.html