HarmonyOS 鸿蒙Next 导入@ohos.base时报错 Cannot find module '@ohos.base' or its corresponding type declarations
HarmonyOS 鸿蒙Next 导入@ohos.base时报错 Cannot find module ‘@ohos.base’ or its corresponding type declarations
导入@ohos.base时报错: Cannot find module ‘@ohos.base’ or its corresponding type declarations.
截图:

更多关于HarmonyOS 鸿蒙Next 导入@ohos.base时报错 Cannot find module '@ohos.base' or its corresponding type declarations的实战教程也可以访问 https://www.itying.com/category-93-b0.html
解决了吗
更多关于HarmonyOS 鸿蒙Next 导入@ohos.base时报错 Cannot find module '@ohos.base' or its corresponding type declarations的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
我也碰到了这个问题,https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/application-models/uiability-lifecycle.md/ 这个里面就用到了这个包,我使用的是API9,但是我在ets\api下没有搜索到这个包,把API卸载,是把SDK全部删除掉重新下载吗
进入模块级oh_package.json5 或者 工程级 oh_package.json5 文件中,查看对应的依赖是否安装。
依赖哪个库呢?
ets/api/@ohos.base 这个依赖在api里面,你在api找找看有没有这个呢
找不到把api卸了,重新下载看看,
在HarmonyOS鸿蒙Next开发中,遇到Cannot find module '@ohos.base' or its corresponding type declarations
报错,通常是由于开发环境未正确配置或依赖缺失导致的。@ohos.base
是鸿蒙系统的核心模块,提供基础API支持。要解决此问题,首先确保开发工具(如DevEco Studio)为最新版本,并已正确配置鸿蒙SDK。检查项目配置文件oh-package.json
,确认@ohos.base
模块已正确声明。若未声明,手动添加依赖项。此外,清理项目缓存并重新构建,确保模块路径正确解析。若问题依旧,检查SDK路径设置,确保其包含@ohos.base
模块。