MAC电脑 Studio安装依赖: ohpm has not been initialized yet. Execute the init script to initialize it first.

问题现象:开发鸿蒙应用时候需要安装三方依赖,运行ohpm install 命令时候报错

ohpm has not been initialized yet. Execute the init script to initialize it first.

解决方案:根据官方文档描述进入ohpm安装目录:

 cd   /Users/zhangying/Library/Huawei/ohpm/bin

运行./init
如果是下载的IDE默认会有这个文件夹。

问题解决:
踩坑如运行后报错

npm WARN @ohos/ohpm@1.2.0 No description
npm WARN @ohos/ohpm@1.2.0 No repository field.

则是node版本不对,检查自己的node版本输入node -v ,node版本需为18.

升级后再次回到目录执行./init,有如下提示则表示正确:

npm warn config init.author.name Use `--init-author-name` instead.
npm warn config init.author.email Use `--init-author-email` instead.
npm warn config init.author.url Use `--init-author-url` instead.
npm warn old lockfile
npm warn old lockfile The package-lock.json file was created with an old version of npm,
npm warn old lockfile so supplemental metadata must be fetched from the registry.
npm warn old lockfile
npm warn old lockfile This is a one-time fix-up, please be patient...
npm warn old lockfile

up to date in 2s

这时候再运行ohpm -v 如提示版本后则安装成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值