本人按照官方文档安装教程结果失败了,于是乎各种查阅最终得以解决,在此记录一下。
1、先查询Ohpm路径:
【DevEco Studio -> Preferences -> Build,Execution,Deployment -> Ohpm -> ohpm home】
![](https://img.haomeiwen.com/i11009126/2757811e1de247ce.png)
![](https://img.haomeiwen.com/i11009126/c43487d502e58a65.png)
将黄色区域的地址复制下,如:【/Users/xxxx/Library/Huawei/ohpm】(xxxx:是自己电脑的名称)
2、将复制的地址尾部加上【/bin】路径,如:【/Users/xxxx/Library/Huawei/ohpm/bin】
终端执行cd
命令进入bin文件夹
cd /Users/xxxx/Library/Huawei/ohpm/bin
终端执行./init
命令初始化ohpm
./init
执行结果如下:
![](https://img.haomeiwen.com/i11009126/6b23011081fa63e7.png)
3、配置 .bash_profile 文件
终端执行vim .bash_profile
打开bash配置文件
vim .bash_profile
![](https://img.haomeiwen.com/i11009126/2ec607b14e8650ba.png)
进入配置文件后按【i】进入编辑模式,将ohpm环境变量配置到文件中(注意替换xxxx),添加成功后先按ESC再输入【:wq】再按回车即可退出编辑。
export OHPM_HOME=/Users/xxxx/Library/Huawei/ohpm
export PATH=${PATH}:${OHPM_HOME}/bin
终端执行source .bash_profile
让配置生效
source .bash_profile
终端执行export
检验否有ohpm路径
export
![](https://img.haomeiwen.com/i11009126/58817841884e7c4d.png)
4、配置 .zshrc 文件
终端执行vim .zshrc
打开zsh配置文件
vim .zshrc
同上将以下信息配置到文件中
export OHPM_HOME=/Users/xxxx/Library/Huawei/ohpm
export PATH=${PATH}:${OHPM_HOME}/bin
终端执行source ~/.zshrc
让配置生效
source ~/.zshrc
最后重启DevEco-Studio开发工具,在Terminal执行ohpm -v
能正常显示版本号
![](https://img.haomeiwen.com/i11009126/88683d8772300313.png)
网友评论