【已解决】Vue packages version mismatch vue@2.5.2 vue-template-compiler@2.4.2

折腾:

【已解决】npm WARN element-ui@2.0.1 requires a peer of vue@^2.5.2 but none was installed

期间,升级vue到2.5.2后,结果npm run dev出错:

  HeadquarterReport git:(permission-control) ✗ npm run dev
> vue-admin-template@1.0.0 dev /Users/crifan/dev/dev_root/xxx
> node build/dev-server.js
> Starting dev server…
ERROR  Failed to compile with 3 errors
error  in ./src/App.vue
Module build failed: Error:
Vue packages version mismatch:
– vue@2.5.2
– vue-template-compiler@2.4.2
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> (/Users/crifan/dev/dev_root/xxx/node_modules/vue-template-compiler/index.js:8:9)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/crifan/dev/dev_root/xxxnode_modules/vue-loader/lib/parser.js:1:78)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)

vue-template-compiler vue mismatch

vue-template-compiler

vuejs/vue: A progressive, incrementally-adoptable JavaScript framework for building UI on the web.

npm – Vue.js 2.3.2 version mismatch – Stack Overflow

重新删除掉:node_modules

后,就可以了。

注意到此处的:

package.json

中有指定:

“vue-template-compiler”: “2.4.2”,

以及:

“vue-loader”: “13.0.4”,

“vue-style-loader”: “3.0.1”,

和:

“vue-router”: “2.7.0”,

“vuex”:  “2.3.1″

所以感觉是:

删除掉vue-template-compiler

然后重新安装就可以了。

vue.js – How do I fix a “Vue packages version mismatch” error on Laravel Spark v4.0.9? – Stack Overflow

Vue 2.0.3 packages version mismatch · Issue #3941 · vuejs/vue

Re-install vue-loader.

npm update vue

打算,去删除掉vue-loader,重新安装vue-loader

先去看看,此处vue的几个模块的依赖情况:

npm list

找到和vue相关的:

├─┬ element-ui@2.0.1
│ ├─┬ async-validator@1.8.1
│ │ └── babel-runtime@6.26.0 deduped
│ ├── babel-helper-vue-jsx-merge-props@2.0.2
│ ├── deepmerge@1.5.2
│ └── throttle-debounce@1.0.1
├── vue@2.5.2
├─┬ vue-loader@13.0.4
│ │ └── uniq@1.0.1
│ ├─┬ resolve@1.5.0
│ │ └── path-parse@1.0.5
│ ├── source-map@0.5.7 deduped
│ ├── vue-hot-reload-api@2.2.0
│ ├── vue-style-loader@3.0.1 deduped
│ └── vue-template-es2015-compiler@1.6.0
├── vue-router@2.7.0
├─┬ vue-style-loader@3.0.1
│ ├── hash-sum@1.0.2 deduped
│ └─┬ loader-utils@1.1.0
│   ├── big.js@3.2.0 deduped
│   ├── emojis-list@2.1.0 deduped
│   └── json5@0.5.1 deduped
├─┬ vue-template-compiler@2.4.2
│ ├── de-indent@1.0.2
│ └── he@1.1.1
├── vuex@2.3.1

此处的vue-template-compiler不依赖其他的。

去找找:

vue-template-compiler

结果不存在这个库了

好像就是属于vue内部的库了。

但是别处也是可以单独安装的:

Please Update vue-template-compiler to the latest version · Issue #1002 · JeffreyWay/laravel-mix

Vue packages version mismatch error · Issue #470 · vuejs/vue-loader

npm install vue-template-compiler –save-dev

所以去卸载和重装vue-template-compiler

➜  HeadquarterReport git:(permission-control) ✗ npm uninstall vue-template-compiler -D
– de-indent@1.0.2 node_modules/de-indent
– vue-template-compiler@2.4.2 node_modules/vue-template-compiler
npm WARN vue-loader@13.0.4 requires a peer of vue-template-compiler@^2.0.0 but none was installed.
npm WARN vue-admin-template@1.0.0 No repository field.
➜  HeadquarterReport git:(permission-control) ✗ npm install vue-template-compiler -D
vue-admin-template@1.0.0 /Users/crifan/dev/dev_root/xxx
└─┬ vue-template-compiler@2.5.2
  └── de-indent@1.0.2
npm WARN vue-admin-template@1.0.0 No repository field.

对应的package.json中也有了最新版本的:

“vue-template-compiler”: “^2.5.2”,

重新npm run dev,结果就可以了。

【总结】

此处升级到vue的2.5.2,结果npm run dev报错:

Vue packages version mismatch:

– vue@2.5.2

– vue-template-compiler@2.4.2

的原因是:

package.json中的devDependencies存在之前的旧版本的vue-template-compiler:

“vue-template-compiler”: “2.4.2”,

和最新的2.5.2的vue不匹配。

解决办法:

卸载重装vue-template-compiler:

npm uninstall vue-template-compiler -D

npm install vue-template-compiler -D

即可。

转载自:在路上 » 【已解决】Vue packages version mismatch vue@2.5.2 vue-template-compiler@2.4.2

发表回复

京ICP备15027918号-1