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”.
更多关于HarmonyOS鸿蒙Next示例项目测试报错ERROR: 10311002 ArkTS: ERROR Error Message: Failed to resolve OhmUrl.的实战教程也可以访问 https://www.itying.com/category-93-b0.html
该错误表明模块解析失败。检查项目依赖配置,确认OhmUrl模块路径是否正确。验证模块是否已正确导入,路径拼写需与项目结构一致。检查模块是否存在,若为第三方库需确保已安装。同步项目依赖,清理构建缓存后重新编译。
这个错误表明项目缺少 @ohos/hypium 测试框架依赖。请按以下步骤解决:
-
检查依赖配置
在entry/package.json中确认已声明依赖:"dependencies": { "@ohos/hypium": "1.0.6" } -
验证模块路径
确保oh_modules目录中存在@ohos/hypium模块。若缺失,执行:npm install -
清理缓存
删除项目根目录的oh_modules、build文件夹,重新运行:hvigorw clean && hvigorw test -
检查SDK版本
确认使用的 HarmonyOS Next SDK 版本与示例项目要求一致,避免兼容性问题。
若问题仍存在,检查网络环境确保依赖下载完整,或尝试切换至稳定版本依赖。


