美文网首页
npm的一些坑

npm的一些坑

作者: dongzhensong | 来源:发表于2020-04-27 09:08 被阅读0次

更换硬盘,电脑重装后,原来的npm中的库各种失效。

1.npm WARN vuex-persist@1.8.0 requires a peer of vuex@>=2.5 but none is installed. You must install peer dependencies yourself.

D:\tcxx_qd>npm install
npm WARN vuex-persist@1.8.0 requires a peer of vuex@>=2.5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

up to date in 15.751s

按照提示手动安装vuex
npm install vuex@^2.5

2.npm run dev报Vue packages version mismatch:

Module build failed: Error:

Vue packages version mismatch:

- vue@2.5.16
- vue-template-compiler@2.5.17

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 ... ... 

处理:

> npm info vue-loader

vue-loader@15.9.1 | MIT | deps: 5 | versions: 240
Vue single-file component loader for Webpack
https://github.com/vuejs/vue-loader

dist
.tarball: https://registry.npm.taobao.org/vue-loader/download/vue-loader-15.9.1.tgz
.shasum: bd2ab8f3d281e51d7b81d15390a58424d142243e

... ...

我的vue-loader版本大于10.0,所以可以通过更新vue-template-compiler,使vue与vue-template-compiler版本一致:

D:\tcxx_qd>npm  update vue-template-compiler
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ vue-template-compiler@2.6.11
updated 1 package in 9.664s

D:\tcxx_qd>npm info vue-template-compiler

vue-template-compiler@2.6.11 | MIT | deps: 2 | versions: 105
template compiler for Vue 2.0
... ... 

D:\tcxx_qd>npm info vue

vue@2.6.11 | MIT | deps: none | versions: 269
Reactive, component-oriented view layer for modern web interfaces.
https://github.com/vuejs/vue#readme

可以看到通过更新vue-template-compiler,vue与 vue-template-compiler都更新到了最新版本(2020-04-27 最新版本v2.6.11)
这样之后,计算机环境下的npm种vue与vue模板编译器版本是一致的,但工程中的vue版本仍是2.5.16,这个时候需要重新在项目中安装vuenpm install vue,安装完成后会提示项目中安装的vue版本

+ vue@2.6.11
updated 1 package in 10.96s

安装完成后再进行 npm run dev就不会有vue与vue模板编译器版本不匹配的提示了。

相关文章

网友评论

      本文标题:npm的一些坑

      本文链接:https://www.haomeiwen.com/subject/czbswhtx.html