想安装Vant插件,出现报错?
报错:
getloon git:(v1.0) ✗ npm i vant@latest-v2 -Snpm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/eslint-config-standard@6.1.0
npm ERR! Found: eslint-plugin-vue@8.7.1
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/eslint-config-standard@6.1.0
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: eslint-plugin-vue@7.20.0
npm ERR! node_modules/eslint-plugin-vue
npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0
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! 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!
npm ERR! For a full report see:
npm ERR! /Users/yangqing/.npm/_logs/2023-04-28T01_27_17_754Z-eresolve-report.txt
回答:
报错信息里写了是eslint-plugin-vue的依赖冲突了,你的node根目录下有一个eslint-plugin-vue,然后你要安装vant最新版本需要另一个eslint-plugin-vue,两者版本不一致导致报错。
解决方法也写了:
1、查询对应的依赖包和npm版本之间的关系 切换到对应的npm版本
2、安装命令带上 --force: 会无视冲突,并强制获取远端npm库资源,即使本地有资源也会覆盖掉
3、安装命令带上 --legacy-peer-deps:安装时忽略所有peerDependencies,忽视依赖冲突,采用之前npm的版本去安装依赖,已有的依赖不会覆盖。
用--legacy-peer-deps 应该就可以了
回答:
错误信息里很明确:你要安装的库,它需要的依赖和你本地的依赖有冲突。
vant 现在都 4.2 了,你还在装 v2,当然会出这样的问题。我不建议 --legacy-peer-deps
,最好用最新版本。
以上是 想安装Vant插件,出现报错? 的全部内容, 来源链接: utcz.com/p/934160.html