HarmonyOS鸿蒙Next中idc自建ohpm-repo无法缓存远端仓库包到本地私有仓库
HarmonyOS鸿蒙Next中idc自建ohpm-repo无法缓存远端仓库包到本地私有仓库
idc部署ohpm-repo私有仓库,web配置uplinks为https://ohpm.openharmony.cn/ohpm,本地通过registry设置私有仓库无法缓存私有仓库中没有的报,直接报404。
终端报错:
ohpm INFO: MetaDataFetcher fetching meta info of package '@rnoh/react-native-openharmony' from https://ohpmtest.xxxx.xxxx/repos/ohpm/
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hypium' from https://ohpmtest.xxx.xxxx/repos/ohpm/
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hamock' from https://ohpmtest.xxxx.xxxx/repos/ohpm/
ohpm DEBUG: Executor all task execute finished.
ohpm DEBUG: Executor Run completed in 0s 99ms
ohpm WARN: fetch meta info of package '@ohos/hamock' failed - GET https://ohpmtest.xxx.xxx/repos/ohpm/@ohos/hamock 404 ( undefined )
ohpm DEBUG: fetch meta info of package '@ohos/hamock' success, but version '1.0.0' not exist https://ohpmtest.xxxx.xxxx/repos/ohpm/@ohos/hamock
ohpm ERROR: NOTFOUND package '@ohos/hamock@1.0.0' not found from all the registries https://ohpmtest.xxx.xxxx/repos/ohpm/
ohpm DEBUG: getOverrideDepFile with key: @ohos/hamock.
ohpm ERROR: missing: @ohos/hamock@1.0.0, required by @
ohpm ERROR: Found exception: Error: FetchPackageInfo: "@ohos/hamock" failed, reached retry limit or non retryable error encountered.
ohpm DEBUG: Executor found task execute failed, exit process!
ohpm DEBUG: Executor Run completed in 0s 196ms
ohpm DEBUG: ERUNNING execute tasks failed, Error: FetchPackageInfo: "@ohos/hamock" failed
ohpm DEBUG: the internal function "genCustomDependency" is not found
ohpm WARN: fetch meta info of package '@ohos/hypium' failed - GET https://ohpmtest.xxx.xxxx/repos/ohpm/@ohos/hypium 404 ( undefined )
ohpm DEBUG: fetch meta info of package '@ohos/hypium' success, but version '1.0.21' not exist https://ohpmtest.xxxx.xxxx/repos/ohpm/@ohos/hypium
ohpm ERROR: NOTFOUND package '@ohos/hypium@1.0.21' not found from all the registries https://ohpmtest.xxxx.xxxx/repos/ohpm/
ohpm DEBUG: getOverrideDepFile with key: @ohos/hypium.
ohpm ERROR: missing: @ohos/hypium@1.0.21, required by @
ohpm ERROR: Found exception: Error: FetchPackageInfo: "@ohos/hypium" failed, reached retry limit or non retryable error encountered.
ohpm WARN: fetch meta info of package '@rnoh/react-native-openharmony' failed - GET https://ohpmtest.xxxx.xxx/repos/ohpm/@rnoh/react-native-openharmony 404 ( undefined )
ohpm DEBUG: fetch meta info of package '@rnoh/react-native-openharmony' success, but version '0.72.44' not exist https://ohpmtest.xxxx.xxxx/repos/ohpm/@rnoh/react-native-openharmony
ohpm ERROR: NOTFOUND package '@rnoh/react-native-openharmony@0.72.44' not found from all the registries https://ohpmtest.xxx.xxxx/repos/ohpm/
ohpm DEBUG: getOverrideDepFile with key: @rnoh/react-native-openharmony.
ohpm ERROR: missing: @rnoh/react-native-openharmony@0.72.44, required by @
ohpm ERROR: Found exception: Error: FetchPackageInfo: "@rnoh/react-native-openharmony" failed, reached retry limit or non retryable error encountered.
ohpm DEBUG: audit successfully, cost: 0s 33ms
ohpm ERROR: Install failed, detail: Error: FetchPackageInfo: "@ohos/hamock" failed
ohpm-repo 服务端报错:
[2025-06-19T09:51:27.604] [ERROR] repoError - package not found: @rnoh/react-native-openharmony.
[2025-06-19T09:51:27.610] [ERROR] repoError - package not found: @ohos/hamock.
[2025-06-19T09:51:27.612] [ERROR] repoError - package not found: @ohos/hypium.
[2025-06-19T09:53:50.775] [ERROR] repoError - package not found: @ohos/hamock.
[2025-06-19T09:53:50.778] [ERROR] repoError - package not found: @ohos/hypium.
[2025-06-19T09:53:50.780] [ERROR] repoError - package not found: @rnoh/react-native-openharmony.
更多关于HarmonyOS鸿蒙Next中idc自建ohpm-repo无法缓存远端仓库包到本地私有仓库的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在IDC部署ohpm-repo私有仓库时,如果无法缓存私有仓库中没有的包并且直接报告,可能原因是:
Uplinks配置 : 你的的web配置uplinks为https://ohpm.openharmony.cn/ohpm,这个配置用于定义ohpm-repo从哪里获取公共的或第三方的包。如果私有仓库中没有某些包,ohpm-repo会尝试从uplinks中配置的源获取这些包。如果这些源也没有相应的包,就会返回404错误。
Registry设置 : 在本地通过registry设置私有仓库时,需要确保registry的设置正确,并且能够正常访问ohpm-repo。如果registry设置不正确,可能无法正确从私有仓库获取包,从而导致缓存问题。
缓存策略 : ohpm-repo的缓存策略通常需要在配置文件中设置。请检查您的配置文件,确保有关缓存的设置能够满足需求。如果缓存策略配置不当,也可能导致无法缓存特定的包。
尝试以下步骤:
- 检查并确认uplinks的配置 :确保uplinks的URL正确,并且能够正常访问。同时,确认uplinks源中是否有尝试获取的包。
- 检查registry的设置 :确认registry的地址是否指向正确的ohpm-repo实例,并且本地系统是否配置了正确的registry地址。
- 调整缓存策略 :根据需求调整缓存策略,确保重要的包能够被有效地缓存下来。
如果以上步骤仍然无法解决问题,建议检查ohpm-repo的日志文件,以获取更详细的错误信息或警告。
更多关于HarmonyOS鸿蒙Next中idc自建ohpm-repo无法缓存远端仓库包到本地私有仓库的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
先确认是否是网络问题:
- 检查本地网络环境,确保可以正常访问 https://ohpm.openharmony.cn/ohpm 。可以使用
ping
命令测试网络连通性,使用curl
命令测试是否能获取远端仓库的内容。
然后检查 ohpm-repo 的配置文件,确保 uplinks
配置正确。
- 手动访问 https://ohpm.openharmony.cn/ohpm 检查请求的包及其版本是不是存在。
清除 ohpm-repo 的缓存,找到 ohpm-repo 的缓存目录,删除其中的缓存文件,然后重启服务。
最后检查 ohpm 的 registry 设置,确保指向本地私有仓库。
这一整套操作下来,大概率可以解决问题
在HarmonyOS鸿蒙Next中,idc自建ohpm-repo无法缓存远端仓库包到本地私有仓库的问题通常与仓库配置或网络权限有关。确保ohpm-repo配置正确,包括repo.json中的仓库地址和包索引更新策略。检查idc网络环境是否允许访问远端仓库,防火墙需开放对应端口。若使用自签名证书,需将其添加到信任列表。本地存储路径需具备写入权限。可通过查看idc日志定位具体失败原因。
从错误日志来看,这是ohpm-repo私有仓库配置问题导致的。关键点在于:
-
您的私有仓库虽然配置了uplinks(https://ohpm.openharmony.cn/ohpm),但实际请求时并没有正确从上游仓库拉取包,而是直接返回404。
-
需要检查ohpm-repo的配置文件,确保:
- uplinks配置正确且可访问
- packages配置中允许从uplinks缓存包(通常需要设置
proxy
属性) - 网络连接正常,能访问上游仓库
-
典型配置示例:
storage: ./storage uplinks: ohpm: url: https://ohpm.openharmony.cn/ohpm packages: '@*/*': proxy: ohpm # 关键配置,允许从uplinks获取 access: $all publish: $authenticated
-
服务端日志显示直接返回"package not found",说明请求根本没有代理到上游仓库,而是直接在本地仓库查找。
建议重点检查ohpm-repo的config.yaml配置文件,特别是packages部分的proxy设置是否正确。