Vue项目启动报错:vue与vue-template-compiler版本不匹配

在启动Vue项目时,你可能会遇到类似这样的错误提示:

'- vue@3.0.0 (D:\Documents\HBuilderProjects\Web-Vue\Vue06\axios\node_modules\vue\index.js)

  • vue-template-compiler@2.7.10 (D:\Documents\HBuilderProjects\Web-Vue\Vue06\axios\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.'

原因:

这个错误提示是因为你的vuevue-template-compiler版本不一致导致的。

解决方法:

根据你使用的vue-loader版本,可以选择以下两种方法之一解决问题:

1. 如果你使用的是vue-loader@>=10.0:

只需要更新vue-template-compiler版本即可。可以使用以下命令来更新:

npm install vue-template-compiler@latest

2. 如果你使用的是vue-loader@<10.0或者vueify:

重新安装vue-loader/vueify会自动更新vue-template-compiler版本。可以使用以下命令来卸载和重新安装:

npm uninstall vue-loader/vueify
npm install vue-loader/vueify

选择其中一种方法解决问题后,重新启动项目即可。

Vue项目启动报错:vue与vue-template-compiler版本不匹配

原文地址: https://www.cveoy.top/t/topic/fPO5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录