在用vue-cli创建project时,

vue create project

出现了vue packages version mismatch的报错

/usr/local/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/index.js:10
  throw new Error(
  ^

Error: 

Vue packages version mismatch:

- vue@2.5.13 (/node_modules/vue/dist/vue.runtime.common.js)
- vue-template-compiler@2.6.10 (/usr/local/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.

    at Object.<anonymous> (/usr/local/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/index.js:10:9)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@vue/cli/node_modules/vue-jscodeshift-adapter/src/parse-sfc.js:1:18)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)

一般的解决方法是更新vue到与vue-template-compiler同版本

npm install vue@2.6.10 --save

如果安装后还是出现相同的报错,有可能是vue的安装与运行环境不符,可尝试加上 `-g` 再装一遍

npm install vue@2.6.10 --save -g
GitHub 加速计划 / vu / vue
207.54 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 4 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 5 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐