"\"F:\DevEco Studio\tools\ohpm\bin\ohpm.bat\"" install --all --registry https://repo.harmonyos.com/ohpm/ --strict_ssl true
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hypium' from https://repo.harmonyos.com/ohpm/
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hamock' from https://repo.harmonyos.com/ohpm/
ohpm ERROR: ETIMEDOUT request to https://repo.harmonyos.com/ohpm/@ohos/hamock failed, reason: connect ETIMEDOUT 183.223.14.103:443, please check the network connectivity to the registry https://repo.harmonyos.com/ohpm/
ohpm ERROR: missing: @ohos/hamock@1.0.0, required by @
ohpm ERROR: ETIMEDOUT request to https://repo.harmonyos.com/ohpm/@ohos/hypium failed, reason: connect ETIMEDOUT 183.223.14.103:443, please check the network connectivity to the registry https://repo.harmonyos.com/ohpm/
ohpm ERROR: missing: @ohos/hypium@1.0.21, required by @
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hamock' from https://repo.harmonyos.com/ohpm/
ohpm INFO: MetaDataFetcher fetching meta info of package '@ohos/hypium' from https://repo.harmonyos.com/ohpm/
ohpm ERROR: ETIMEDOUT request to https://repo.harmonyos.com/ohpm/@ohos/hypium failed, reason: connect ETIMEDOUT 183.223.14.103:443, please check the network connectivity to the registry https://repo.harmonyos.com/ohpm/
ohpm ERROR: missing: @ohos/hypium@1.0.21, required by @
ohpm ERROR: Found exception: FetchError: request to https://repo.harmonyos.com/ohpm/@ohos/hypium failed, reason: connect ETIMEDOUT 183.223.14.103:443, reached retry limit or non retryable error encountered.
ohpm ERROR: ETIMEDOUT request to https://repo.harmonyos.com/ohpm/@ohos/hamock failed, reason: connect ETIMEDOUT 183.223.14.103:443, please check the network connectivity to the registry https://repo.harmonyos.com/ohpm/
ohpm ERROR: missing: @ohos/hamock@1.0.0, required by @
ohpm ERROR: Found exception: FetchError: request to https://repo.harmonyos.com/ohpm/@ohos/hamock failed, reason: connect ETIMEDOUT 183.223.14.103:443, reached retry limit or non retryable error encountered.
ohpm ERROR: Install failed, detail: FetchError: request to https://repo.harmonyos.com/ohpm/@ohos/hypium failed, reason: connect ETIMEDOUT 183.223.14.103:443
Process finished with exit code 1
【背景知识】
- ohpm作为OpenHarmony三方库的包管理工具,支持OpenHarmony共享包的发布、安装和依赖管理。
- .ohpmrc是ohpm的配置文件,ohpm从命令行和.ohpmrc文件中获取其配置设置。ohpm config命令可用于修改用户级.ohpmrc文件的内容。
更多配置文件知识可以参考:ohpmrc。
【解决方案】
- 排查.ohpmrc中是否配置了正确的中心仓地址。
项目级配置文件:/path/to/my/project/.ohpmrc。
用户级配置文件:
MacOS默认位置:~/.ohpm/.ohpmrc。
windows操作系统默认位置:C:\Users\用户名\.ohpm\.ohpmrc。### 仓库配置,支持配置多个地址,使用英文逗号分隔。 registry=https://ohpm.example.com/ohpm,https://repo.example.com/ohpm -
若无法访问中心仓,需要确认当前网络连接是否正常,保证可以访问公网。
-
排查网络代理问题,如网络环境需要使用代理,ohpm代理信息,在http_proxy和https_proxy中,将user、password、proxyserver和port按照实际代理服务器进行修改。示例如下:
http_proxy=http://用户名:密码@域名或IP:端口 https_proxy=http://用户名:密码@域名或IP:端口如果password中存在特殊字符,如@、#、*等符号,可能导致配置不生效,建议将特殊字符替换为ASCII码,并在ASCII码前加百分号%。常用符号替换为ASCII码对照表如下:
特殊符号 ASCII码 ! %21 @ %40 # %23 $ %24 & %26 * %2A - 确认以上配置成功后,正常就可以下载OpenHarmony三方库中心仓中的库,但是如果想要下载的库没有上传到官方中心仓,例如阿里云的mPaas,需要在.ohpmrc中根据group指定组织的仓库地址。支持多个仓库地址,以英文逗号间隔,且优先级大于registry配置,多个仓库地址的优先级按照配置顺序排序。
registry=https://ohpm.example.cn/ohpm,https://repo.example.com/ohpm ### 指定仓库地址 @mpaas:registry=https://mpaas-ohpm.example.com/meta - ohpm默认忽略SSL证书校验,如果需要开启,则需要在.ohpmrc中配置有效的的证书路径,否则也会导致下载失败。
strict_ssl=true ca_files=/path/to/cert
【常见FAQ】 Q:执行ohpm install安装依赖成功,但是没看到安装的依赖。 A:注意执行ohpm install的路径,oh-package.json5分为模块级和工程级,需要在执行安装命令的路径下查看oh-package.json5和oh_modules。