HarmonyOS鸿蒙Next中hvigor ERROR: 00308021 Operation Error
HarmonyOS鸿蒙Next中hvigor ERROR: 00308021 Operation Error 项目目录中已经配置了.npmrc,内容为registry=https://repo.huaweicloud.com/repository/npm/
proxy=http://账户:密码@proxyhk.huawei.com:8080/
https-proxy=http://账户:密码@proxyhk.huawei.com:8080/
strict-ssl=false
但是编译报错,
D:\SoftWare\DevEco_Studio\tools\node\node.exe D:\SoftWare\DevEco_Studio\tools\hvigor\bin\hvigorw.js clean --mode module assembleHap --analyze=normal --parallel --incremental --daemon
Installing dependencies…
hvigor ERROR: 00308021 Operation Error
Error Message: C:\Users\xx.hvigor\wrapper\tools\node_modules.bin\pnpm.cmd install execute failed. More details:
WARN GET [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhypium-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhypium-plugin) error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
WARN GET [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin) error (ETIMEDOUT). Will retry in 10 seconds. 2 retries left.
WARN GET [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin) error (ETIMEDOUT). Will retry in 1 minute. 1 retries left.
WARN GET [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhypium-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhypium-plugin) error (ETIMEDOUT). Will retry in 1 minute. 1 retries left.
ERR_PNPM_META_FETCH_FAIL GET [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin): request to [https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin](https://repo.huaweicloud.com/repository/npm/@ohos%2Fhvigor-ohos-online-sign-plugin) failed, reason: connect ETIMEDOUT 14.29.44.93:443
This error happened while installing a direct dependency of C:\Users\xxx.hvigor\project_caches\2eba90e7ee1fbca51fbd6b8c9b4d6d43\workspac
-
Try the following:
Ensure that the npm repository address is accessible.
Contact the repository provider or replace the npm repository address.
Process finished with exit code -1
也无法访问
ping repo.huaweicloud.com
正在 Ping hcdnd.cbg.c.cdnhwc2.com [14.29.44.93] 具有 32 字节的数据:
请求超时。
,是什么原因,如何解决
更多关于HarmonyOS鸿蒙Next中hvigor ERROR: 00308021 Operation Error的实战教程也可以访问 https://www.itying.com/category-93-b0.html
尊敬的开发者,您好,
根据报错信息,可以参考00308021 npm仓库中无法获取包的元数据文档描述,可能是网络问题,或npm仓库地址配置错误。
可按以下步骤排查看是否解决问题。
- 请确保仓库地址可以访问,查看npm配置的仓库地址是否正确、是否有防火墙或代理限制等。
- 联系仓库提供方确认仓库地址是否可用,或更换新的npm仓库地址。
若未能解决问题可以提供完整复现代码和详细的日志(1.打开cmd 2.清除:hdc shell hilog -r 3.监听抓日志:hdc shell hilog >log.txt),当前开发工具版本(Help->About DevEco Studio)、运行时API版本(File->Project Structure->Project->Basic Info->Compatible SDK)、手机系统版本信息 (设置->关于本机),感谢您的理解与支持。
更多关于HarmonyOS鸿蒙Next中hvigor ERROR: 00308021 Operation Error的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
该错误码 00308021 表示 Hvigor 在构建过程中遇到操作异常。可能原因:模块配置错误、资源文件缺失或损坏、签名证书无效、Hvigor 版本不兼容。请检查构建日志中具体操作步骤以定位问题,并验证项目配置与依赖完整性。
此错误是因为hvigor依赖安装时,pnpm无法连接华为npm仓库(repo.huaweicloud.com),出现ETIMEDOUT超时。从日志看,你的环境已配置代理(proxyhk.huawei.com),但访问仓库仍失败,说明代理未生效或无法转发到仓库地址。ping不通也表明网络层不通。
原因:
- 代理服务器可能未放通
repo.huaweicloud.com或特定端口(443),或代理配置方式未覆盖pnpm。 - 在
.npmrc中直接设置proxy和https-proxy,pnpm可能未继承该配置(尤其当安装过程在独立的工作区目录下执行)。 - 内网环境下可能还存在其他防火墙或策略限制。
解决:
- 尝试在系统环境变量中设置
HTTP_PROXY和HTTPS_PROXY(格式http://账户:密码@proxyhk.huawei.com:8080/),重启终端或DevEco Studio后重新编译。 - 若代理不支持https代理仓库(常见https代理会单独配置),确保
https-proxy也已设置,且代理服务器允许访问repo.huaweicloud.com:443。 - 如果仍超时,可更换网络环境(如切换到手机热点)快速验证是否为网络限制,再根据结果联系网络管理员开通白名单。

