配置环境
- 操作系统: Manjaro Linux
- 内核版本: 4.19.113-1-MANJARO
- 操作系统类型: 64-位
- 处理器: 12 × Intel® Core™ i7-8750H CPU @ 2.20GHz
- 内存: 15.5 GiB 内存
Node
:13.12.0
yarn
:1.22.4
问题描述
当我们很长一段时间没有使用 vue-cli
,在更新之后,vue create xxx
时可能会出现:
Vue packages version mismatch:
vue@2.5.17 (xxxx/node_modules/vue/dist/vue.runtime.common.js)
vue-template-compiler@2.6.10 (/Users/vincentdupont/.nvm/versions/node/v8.9.0/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/package.json)
This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.
原因分析
由于 lock
文件的存在,导致实际使用的 vue-template-compiler
与 vue
版本出现不对等的问题。
解决方案
- 找到
yarn global
的目录,通常为~/.config/yarn/global
。 - 删除
yarn.lock
。 - 再重新安装
vue-cli
即可(理论上在上面那个目录直接yarn install
也可以)。