配置环境
Node
:13.12.0
yarn
:1.22.4
问题描述
当我们很长一段时间没有使用 vue-cli
,在更新之后,vue create xxx
时可能会出现:
Vue packages version mismatch:
[email protected] (xxxx/node_modules/vue/dist/vue.runtime.common.js)[email protected] (/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
也可以)。