HarmonyOS鸿蒙Next示例项目测试报错ERROR: 10311002 ArkTS: ERROR Error Message: Failed to resolve OhmUrl.

HarmonyOS鸿蒙Next示例项目测试报错ERROR: 10311002 ArkTS: ERROR Error Message: Failed to resolve OhmUrl. 下载的示例项目HarmonyOS_Samples/TextExpand

运行hvigorw test命令

hvigor ERROR: ArkTS Compiler Error

1 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “@ohos/hypium” imported by “D:\harmonyOS\TextExpand\entry.test\testability\pages\Index.ets”.

  • Try the following:

    Check whether the “undefined” module which @ohos/hypium belongs to is correctly configured.

    Check if the corresponding file name “@ohos/hypium” is correct(including case-sensitivity).


更多关于HarmonyOS鸿蒙Next示例项目测试报错ERROR: 10311002 ArkTS: ERROR Error Message: Failed to resolve OhmUrl.的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

是不是在项目根 oh-package.json5 中的 “modules”: [] 中忘记了添加自己的模块引用,导致项目识别不到特定的模块。

更多关于HarmonyOS鸿蒙Next示例项目测试报错ERROR: 10311002 ArkTS: ERROR Error Message: Failed to resolve OhmUrl.的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


该错误表明模块解析失败。检查项目依赖配置,确认OhmUrl模块路径是否正确。验证模块是否已正确导入,路径拼写需与项目结构一致。检查模块是否存在,若为第三方库需确保已安装。同步项目依赖,清理构建缓存后重新编译。

这个错误表明项目缺少 @ohos/hypium 测试框架依赖。请按以下步骤解决:

  1. 检查依赖配置
    entry/package.json 中确认已声明依赖:

    "dependencies": {
      "@ohos/hypium": "1.0.6"
    }
    
  2. 验证模块路径
    确保 oh_modules 目录中存在 @ohos/hypium 模块。若缺失,执行:

    npm install
    
  3. 清理缓存
    删除项目根目录的 oh_modulesbuild 文件夹,重新运行:

    hvigorw clean && hvigorw test
    
  4. 检查SDK版本
    确认使用的 HarmonyOS Next SDK 版本与示例项目要求一致,避免兼容性问题。

若问题仍存在,检查网络环境确保依赖下载完整,或尝试切换至稳定版本依赖。

回到顶部