问题现象:开发鸿蒙应用时候需要安装三方依赖,运行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
如提示版本后则安装成功。