Homebrew的安装和使用

Homebrew是什么

  • Homebrew是一款Mac
    OS平台下的软件包管理工具,拥有安装卸载更新查看搜索等很多实用的功能。简单的一条指令,就可以实现包管理,无需关心各种依赖和文件路径的情况,十分方便快捷。

Homebrew的安装和卸载

  1. 在命令行中执行以下命令
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. 卸载Homebrew
      $ cd `brew --prefix`
      $ rm -rf Cellar
      $ brew prune
      $ rm `git ls-files`
      $ rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
      $ rm -rf .git
      $ rm -rf ~/Library/Caches/Homebrew
    
    

Homebrew常用命令

  1. 安装软件
    	brew install 软件名称
    
  2. 卸载软件
    	brew uninstall 软件名称
    
  3. 查询软件
    	brew search 软件名称
    
  4. 列出所有已安装的软件
    	brew list
    
  5. 更新Homebrew
    	brew update
    
  6. 更新软件
    	brew upgrade 软件名
    
  7. 查看软件信息
    	brew info 软件名称
    
  8. 查看软件的依赖包
    	brew deps
    
  9. 查看Homebrew是否正常运行
    	brew doctor
    
  10. 查看Homebrew版本信息
    	brew -v
    

更新Homebrew数据源

	# 替换brew.git:
	$ cd "$(brew --repo)"
	# 中国科大:
	$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
	# 清华大学:
	$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
	
	# 替换homebrew-core.git:
	$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
	# 中国科大:
	$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
	# 清华大学:
	$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
	
	# 替换homebrew-bottles:
	# 中国科大:
	$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
	$ source ~/.bash_profile
	# 清华大学:
	$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
	$ source ~/.bash_profile
	
	# 应用生效:
	$ brew update

重置Homebrew数据源

	# 重置brew.git:
	$ cd "$(brew --repo)"
	$ git remote set-url origin https://github.com/Homebrew/brew.git
	
	# 重置homebrew-core.git:
	$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
	$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
使用Homebrew安装nvm的步骤如下: 1. 首先,确保你已经安装Homebrew。如果没有安装,你可以通过在终端中运行以下命令来进行安装: ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 2. 确保你已经安装了Node.js。如果没有安装,你可以使用Homebrew在终端中运行以下命令来安装Node.js: ``` brew install node ``` 3. 接下来,你需要安装nvm。在终端中运行以下命令: ``` brew install nvm ``` 4. 安装完成后,你需要编辑你的shell配置文件(例如 ~/.bash_profile, ~/.zshrc, ~/.profile 等),添加nvm的配置。根据你的shell类型,你需要选择对应的配置文件。 如果你使用的是bash shell,可以在终端中运行以下命令来编辑配置文件: ``` echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bash_profile echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm' >> ~/.bash_profile echo '[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion' >> ~/.bash_profile source ~/.bash_profile ``` 如果你使用的是zsh shell,可以在终端中运行以下命令来编辑配置文件: ``` echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm' >> ~/.zshrc echo '[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion' >> ~/.zshrc source ~/.zshrc ``` 5. 完成以上步骤后,你可以在终端中运行以下命令来验证nvm是否成功安装: ``` nvm --version ``` 通过以上步骤,你就可以使用Homebrew安装并配置nvm了。注意,nvm会覆盖掉已经安装的Node.js版本,所以请确保在安装nvm之前备份好你的Node.js安装。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [MAC:homebrew安装nvm及node](https://blog.csdn.net/Froth__/article/details/129717748)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值