Vue packages version mismatch: 版本始终不对

vue安装依赖包时,遇到了一个问题,如下

Vue packages version mismatch:

vue@2.6.12
vue-template-compiler@2.6.10
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.

经过排查发现,package.json中vue的版本配置如下:

"vue": "^2.6.10"

在安装依赖包时,会自动安装符合条件的高于或等于2.6.10版本的,所有这里安装了2.6.12版本
但与vue-template-compiler@2.6.10版本不符合

解决方法有两个:

方法一:

重新安装 npm i vue-template-compiler@2.6.12 --save

方法二:

修改package.json中vue的版本配置如下:

去掉‘^’,代表安装时就会安装2.6.10版本的vue,不会匹配高版本

原文地址:https://www.cnblogs.com/wangyingblock/p/14118774.html