報錯信息為:
ERROR Error:
Vue packages version mismatch:
- vue@2.6.10 (D:\softwares\node\node_global\node_modules\vue\dist\vue.runtime.common.js)
- vue-template-compiler@2.6.11 (D:\softwares\node\node_global\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.
解決方法:
npm uninstall vue-template-compiler //卸載掉已經安裝的版本
npm i vue-template-compiler@當前版本號 --save //這里的版本號是當前vue的版本號
沒成功。
換一種方法:
npm install
npm update
重復執行了好幾次,還是不行。
最后根據碼工思博博主的思路,發現是之前vue2.0的版本沒清除干凈,找到 vue.runitme.common.js 這個文件刪除它(根據報錯里提示的路徑找本文件,本機路徑為:D:\softwares\node\node_global\node_modules\vue\dist\vue.runtime.common.js)。
成功。