npm安装Vant报错

本文介绍了在Vue2环境中安装Vant遇到的版本问题,建议卸载vant并针对Vue2和Vue3分别进行版本安装,以避免运行时的错误。
摘要由CSDN通过智能技术生成

安装

一般都是安装的版本问题:

先去除已安装的vant:npm uninstall vant

  • vue2全局安装Vant:npm i vant@latest-v2 -S
  • vue3全局安装Vant:npm i vant -S

使用vue2安装vant常见错误说明

如果直接使用npm i vant -S安装了vant,则报版本冲突不允许安装,如果强制使用 npm i -S --legacy-peerdeps 或者使用 npm i vant -S --force 强制性不管版本安装了vant,虽然可以安装,但是运行时会出现如下错误

ERROR in ./node_modules/vant/es/watermark/Watermark.mjs 55:46-58
export 'createVNode' (imported as '_createVNode') was not found in 'vue' (possible exports: EffectScope, computed, customRef, default, defineAsyncComponent, defineComponent, del, effectSc
ope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBe
foreUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly
, ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect)
 @ ./node_modules/vant/es/watermark/index.mjs 2:0-41 3:30-40 5:0-49 6:0-63
 @ ./node_modules/vant/es/index.mjs 101:0-50 104:1048-1057 214:0-38 214:0-38
 @ ./src/main.js 4:0-24 8:8-12

  • 报错信息提示vant版本过高,vue2的版本无法解析。说明你是在vue2安装vant,需要卸载vant,然后安装vue2版本的vant。 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值