在vue2环境下,默认安装 npm install vue-i18n 的版本是 vue-i18n@9.1.9,所以报错信息如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: x-touch@0.1.0
npm ERR! Found: vue@2.6.14
npm ERR! node_modules/vue
npm ERR! vue@"^2.6.11" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0.0" from vue-i18n@9.1.9
npm ERR! node_modules/vue-i18n
npm ERR! vue-i18n@"*" 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!
**peer vue@“^3.0.0” from vue-i18n@9.1.9 ** 这段意思是 版本不匹配
我们可以使用下面命令查看 vue-i18n 所有版本:
npm view vue-i18n versions --json

然后找到合适的版本即可,这里使用的是 5.0.0
npm install vue-i18n@5
在Vue2项目中安装vue-i18n@9.1.9时遇到依赖冲突,报错信息提示需要vue@^3.0.0,但项目使用的是vue@2.6.14。为解决这个问题,可以查看vue-i18n的版本列表,选择兼容Vue2的版本,例如使用5.0.0。通过运行`npm install vue-i18n@5`来安装合适版本,从而避免版本不匹配导致的错误。
3153

被折叠的 条评论
为什么被折叠?



