昨天在拉代码下来安装依赖成功后,对项目进行编译启动,结果报错了,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.
,再一看发现是因为vue的版本和vue-template-compiler的版本不一样,vue是[email protected]
版本,vue-template-compiler是[email protected]
版本。
一、报错
Vue packages version mismatch:
- [email protected] (E:\项目xxx-mobile\node_modules\vue\dist\vue.runtime.common.js)
- [email protected] (E:\项目\xxx-mobile\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.
at Object.<anonymous> (E:\项目\xxx-mobile\node_modules\vue-template-compiler\index.js:10:9)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadFromContext (E:\项目\xxx-mobile\node_modules\vue-loader\lib\compiler.js:30:10)
at loadTemplateCompiler (E:\项目\xxx-mobile\node_modules\vue-loader\lib\compiler.js:37:12)
at exports.resolveCompiler (E:\项目\xxx-mobile\node_modules\vue-loader\lib\compiler.js:25:23)
at VueLoaderPlugin.apply (E:\项目\xxx-mobile\node_modules\vue-loader\lib\plugin-webpack5.js:144:22)
at createCompiler (E:\项目\xxx-mobile\node_modules\webpack\lib\webpack.js:73:12)
at create (E:\项目\xxx-mobile\node_modules\webpack\lib\webpack.js:134:16)
at webpack (E:\项目\xxx-mobile\node_modules\webpack\lib\webpack.js:158:32)
at WebpackCLI.f [as webpack] (E:\项目\xxx-mobile\node_modules\webpack\lib\index.js:64:16)
at WebpackCLI.createCompiler (E:\项目\xxx-mobile\node_modules\webpack-cli\lib\webpack-cli.js:1789:29)
error Command failed with exit code 2.
二、解决方法
将 vue的版本 和 vue-template-compiler的版本改成一致
npm i [email protected] --save
建议先将原来的 vue-template-compiler 删除,再重新进行安装