想安装Vant插件,出现报错?

作者站长头像
站长
· 阅读数 18

报错:

 getloon git:(v1.0) ✗ npm i vant@latest-v2 -S
npm 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

回复
1个回答
avatar
test
2024-07-05

报错信息里写了是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 应该就可以了

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容