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

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

| 开发环境 | 版本号 | 项目创建方式 |
|---------|-------|--------------|
| Windows | win11 | HBuilderX     |

# bug描述:

20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.093 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'. [D:/a/dist/release/com.example.test.template/entry/build/release/cache/default/default@CompileArkTS/esmodule/release/entry/src/main/resources/rawfile/apps/HBuilder/www/app-service.js:901:811]
The size of programs is expected to be 139, but is 138

## 示例代码:

20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.093 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'. [D:/a/dist/release/com.example.test.template/entry/build/release/cache/default/default@CompileArkTS/esmodule/release/entry/src/main/resources/rawfile/apps/HBuilder/www/app-service.js:901:811]
The size of programs is expected to be 139, but is 138

## 操作步骤:

20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.093 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'. [D:/a/dist/release/com.example.test.template/entry/build/release/cache/default/default@CompileArkTS/esmodule/release/entry/src/main/resources/rawfile/apps/HBuilder/www/app-service.js:901:811]
The size of programs is expected to be 139, but is 138

## 预期结果:

20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.093 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'. [D:/a/dist/release/com.example.test.template/entry/build/release/cache/default/default@CompileArkTS/esmodule/release/entry/src/main/resources/rawfile/apps/HBuilder/www/app-service.js:901:811]
The size of programs is expected to be 139, but is 138

## 实际结果:

20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.091 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.092 > hvigor WARN: The current module 'com.example.test.template' has dependency which is not installed at its oh-package.json5.
20:19:26.093 > hvigor ERROR: ArkTS:ERROR Failed to execute es2abc.
Error Message: SyntaxError: Unexpected token, expected '}'. [D:/a/dist/release/com.example.test.template/entry/build/release/cache/default/default@CompileArkTS/esmodule/release/entry/src/main/resources/rawfile/apps/HBuilder/www/app-service.js:901:811]
The size of programs is expected to be 139, but is 138

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

1 回复

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


在处理 uni-app 打包鸿蒙APP时遇到 hvigor ERROR ArkTS ERROR Failed to execute es2abc 错误,通常表示在将 ECMAScript 代码转换为鸿蒙系统的ArkTS(Ark TypeScript)中间表示形式时出现了问题。这个问题可能由多种原因引起,包括代码问题、依赖问题或配置错误等。以下是一些可能的解决方案和相关的代码案例,帮助你定位和解决问题。

1. 检查项目依赖

确保所有依赖都已正确安装,并且版本兼容。可以通过运行以下命令来安装或更新依赖:

npm install

或者,如果你使用的是 yarn:

yarn install

2. 检查 tsconfig.json 配置

确保 tsconfig.json 文件中的配置适用于鸿蒙开发。以下是一个基本的 tsconfig.json 示例,适用于ArkTS项目:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "lib": ["es2020", "dom"],
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "include": ["src/**/*"]
}

3. 检查 Babel 配置

如果你的项目使用了 Babel,确保 Babel 配置正确。以下是一个 .babelrc 示例:

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-typescript"
  ],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}

4. 清理和重建

有时候,简单的清理和重建项目可以解决问题。你可以尝试删除 distbuild 目录,然后重新运行构建命令:

npm run build:mp-harmonyos

或者,如果你使用的是自定义的构建脚本,确保它正确调用了 uni-app 的构建命令。

5. 查看详细错误日志

如果上述步骤都不能解决问题,建议查看更详细的错误日志,了解是哪个文件或哪段代码导致了编译失败。你可以在构建命令后添加 --verbose 标志来获取更多信息。

结论

hvigor ERROR ArkTS ERROR Failed to execute es2abc 错误通常与代码转换有关。通过上述步骤,你应该能够定位并解决问题。如果问题仍然存在,可能需要更深入地检查代码或咨询鸿蒙开发社区。

回到顶部