uni-app 打包鸿蒙app报错 hvigor ERROR: ArkTS:ERROR Failed to execute es2abc

发布于 1周前 作者 bupafengyu 来自 Uni-App

uni-app 打包鸿蒙app报错 hvigor ERROR: ArkTS:ERROR Failed to execute es2abc

产品分类

uniapp/App

PC开发环境

项目
操作系统 Windows
版本号 win11

手机系统

项目
系统 HarmonyOS NEXT
版本号 HarmonyOS NEXT Developer Beta2
厂商 模拟器
机型 华为

开发工具

项目
HBuilderX 正式
版本号 4.29

其他信息

项目
页面类型 vue
vue版本 vue3
打包方式 云端
项目创建方式 HBuilderX

示例代码

01:05:23.044 项目 myvue 编译成功。
01:05:23.127 打包生成 .app ............
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.071 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'.

操作步骤

01:05:23.044 项目 myvue 编译成功。
01:05:23.127 打包生成 .app ............
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.071 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'.

预期结果

01:05:23.044 项目 myvue 编译成功。
01:05:23.127 打包生成 .app ............
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.071 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'.

实际结果

01:05:23.044 项目 myvue 编译成功。
01:05:23.127 打包生成 .app ............
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.071 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'.

bug描述

01:05:23.044 项目 myvue 编译成功。
01:05:23.127 打包生成 .app ............
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.070 > hvigor WARN: The current module 'myvue.huawei.com' has dependency which is not installed at its oh-package.json5.
01:06:10.071 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'.

更多关于uni-app 打包鸿蒙app报错 hvigor ERROR: ArkTS:ERROR Failed to execute es2abc的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

看报错信息是语法错误,你检查一下代码看看是哪里的问题,比如 uts 插件之类的

更多关于uni-app 打包鸿蒙app报错 hvigor ERROR: ArkTS:ERROR Failed to execute es2abc的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在处理使用uni-app打包鸿蒙应用时遇到的hvigor ERROR: ArkTS:ERROR Failed to execute es2abc错误,这通常指示在将ECMAScript代码转换为鸿蒙系统的ArkTS(Ark TypeScript)过程中出现了问题。以下是一些可能的解决方案和相关的代码案例来帮助你解决这个问题。

1. 确保环境配置正确

首先,确保你的开发环境已经正确配置,包括Node.js版本、uni-app CLI版本以及鸿蒙SDK版本。鸿蒙开发需要特定的环境要求,比如Node.js版本应在LTS版本范围内。

2. 检查manifest.json配置

manifest.json文件是uni-app项目的配置文件,确保其中关于鸿蒙平台的配置是正确的。特别是mp-harmonyos部分,确保所有必要的配置项都已正确填写。

{
  "mp-harmonyos": {
    "appid": "your-app-id",
    "setting": {
      // 其他配置...
    }
  }
}

3. 清理和重建项目

有时候,简单的清理和重建项目可以解决编译过程中遇到的问题。你可以尝试删除dist目录和node_modules目录,然后重新运行npm installuni-app的打包命令。

rm -rf dist node_modules
npm install
npx uni-app-cli build -p mp-harmonyos

4. 检查源代码中的ES6+语法

es2abc工具负责将ECMAScript代码转换为ArkTS,如果你的代码中使用了不被支持的ES6+语法,可能会导致转换失败。确保你的代码符合鸿蒙系统的要求,或者尝试使用Babel等工具转译代码。

5. 查看详细的编译日志

通常,编译工具会提供更详细的错误信息在日志中。尝试运行打包命令时加上--verbose参数,以获取更详细的输出,这有助于定位问题。

npx uni-app-cli build -p mp-harmonyos --verbose

6. 更新uni-app和鸿蒙SDK

确保你使用的uni-app框架和鸿蒙SDK都是最新版本,因为新版本可能修复了旧版本中的bug。

npm update -g @dcloudio/uni-app-cli
# 检查并更新鸿蒙SDK,具体步骤根据鸿蒙官方文档

如果以上步骤都不能解决问题,建议查看uni-app和鸿蒙开发的官方社区和论坛,看看是否有其他开发者遇到并解决了类似的问题。此外,提交issue到uni-app的GitHub仓库也是一个不错的选择。

回到顶部