uni-app "openBlock" is not exported by "node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"

uni-app “openBlock” is not exported by “node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js”

操作步骤:

  • npm run dev:mp-weixin

预期结果:

  • 不报错,可正常运行

实际结果:

  • node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js (1:79): “openBlock” is not exported by “node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js”, imported by “node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js”.
  • at …/node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js:1:79 1: import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide… 2: import { isArray, isString, extend, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, … 3: import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, resolveComponentInstance, normalizeStyles,…

bug描述:

  • 附件中有demo运行报错。使用npm run dev:h5运行正常。
  • npm run dev:mp-weixin
  • node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js (1:79): “openBlock” is not exported by “node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js”, imported by “node_modules/@dcloudio/uni-h5/dist/uni-h5.es.js”.
信息类别 详情
产品分类 uniapp/小程序/微信
PC开发环境操作系统 Windows
PC开发环境操作系统版本号 Windows 11 企业版
HBuilderX类型 正式
HBuilderX版本号 4.57
第三方开发者工具版本号 1
基础库版本号 3.0.0-4050720250324001
项目创建方式 HBuilderX

blank-app-vue3.zip


更多关于uni-app "openBlock" is not exported by "node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

更多关于uni-app "openBlock" is not exported by "node_modules/@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js"的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这个错误通常是由于uni-app版本不匹配或依赖冲突导致的。以下是解决方案:

  1. 首先确保你的项目是Vue3项目,因为openBlock是Vue3的API

  2. 尝试以下步骤:

  • 删除node_modules和package-lock.json
  • 确保package.json中uni-app相关依赖版本一致:
"[@dcloudio](/user/dcloudio)/uni-app": "^3.0.0-4050720250324001",
"[@dcloudio](/user/dcloudio)/uni-mp-weixin": "^3.0.0-4050720250324001",
"[@dcloudio](/user/dcloudio)/uni-h5": "^3.0.0-4050720250324001"
  • 运行npm install
  1. 如果问题仍然存在,可以尝试:
  • 升级HBuilderX到最新稳定版
  • 使用HBuilderX创建新项目,将代码迁移过去
  1. 临时解决方案(不推荐长期使用): 在vite.config.js中添加:
optimizeDeps: {
  exclude: ['[@dcloudio](/user/dcloudio)/uni-h5']
}
回到顶部