一、下载ohpm命令行工具
https://developer.harmonyos.com/cn/develop/deveco-studio#download_cli
二、安装ohpm
1、下载后修改文件夹名称放到/Users/xxx目录下
2、打开命令行工具cd到/Users/xx/Huawei/ohpm/bin
运行如下命令:
cd /Users/xx/Huawei/ohpm/bin
./init
3、打开终端配置环境变量
export OHPM_HOME=/Users/xx/Huawei/ohpm/bin
export PATH=${PATH}:${OHPM_HOME}/bin
4、配置.zshrc及.bash_profile
我看官网文档教程没有介绍这块,导致全局根本引用不到ohpm
zsh:
1. touch ~/.zshrc
2. open ~/.zshrc
3. 把 export OHPM_HOME=/Users/xx/Huawei/ohpm
export PATH=${PATH}:${OHPM_HOME}/bin
粘贴进去,保存即可
4. source ~/.zshrc
bash:
1. touch ~/.bash_profile
2. open ~/.bash_profile
3. 把 export OHPM_HOME=/Users/xx/Huawei/ohpm
export PATH=${PATH}:${OHPM_HOME}/bin
粘贴进去,保存即可
4. source ~/.bash_profile