Homebrew -- 安装与使用

使用 React Native,必须安装的依赖有:Node、Watchman 和 React Native 命令行工具以及 Xcode。php

推荐使用Homebrew来安装 Node 和 Watchman。html

一、Homebrew是什么? git

Homebrew是以最简单,最灵活的方式来安装苹果公司在MacOS中不包含的UNIX工具。 换句话说就是macOS 缺失的软件包的管理器。github

官方网站:点击查看xcode

Git仓库地址:点击查看ruby

二、Homebrew 安装:bash

打开mac终端,复制粘贴下面命令,根据要求,一步一步便可。app

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"curl

三、Homebrew卸载:ide

打开mac终端,复制粘贴下面命令(其实只用把上面安装的install换成uninstall就好了)。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

四、Homebrew 怎么使用?经常使用命令有哪些?

安装软件,如:brew install oclint

卸载软件,如:brew uninstall oclint

搜索软件,如:brew search oclint

更新软件,如:brew upgrade oclint

查看安装列表, 如:brew list

更新Homebrew,如:brew update

五、安装中遇到的问题

(1)错误描述以下:

xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'

Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

缘由:xcode的命令行工具再也不安装在/Library/Developer/CommandLineTools 这个位置了,而是以下图所示的位置:

/Applications/Xcode.app 

这个时候只须要使用下面这个命令设置一下就能够了:

sudo xcode-select --switch /Applications/Xcode.app

最后再输入下面命令验证一下:

xcode-select -p

打印输出

/Applications/Xcode.app/Contents/Developer

而后再尝试安装命令,就没有出现上面的那个问题了。

想法:我的以为上面的那个问题能够不用管,由于xcode 已经自动安装了CommandLineTools这个工具。

六、详细的流程:

$ sudo xcode-select --switch /Applications/Xcode.app

Password:

$ xcode-select -p

/Applications/Xcode.app/Contents/Developer

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

==> This script will install:

/usr/local/bin/brew

/usr/local/share/doc/homebrew

/usr/local/share/man/man1/brew.1

/usr/local/share/zsh/site-functions/_brew

/usr/local/etc/bash_completion.d/brew

/usr/local/Homebrew

==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort

==> Searching online for the Command Line Tools

==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

==> Installing Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.4

==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ (macOS\ High\ Sierra\ version\ 10.13)\ for\ Xcode-9.4

Software Update Tool

Downloading Command Line Tools (macOS High Sierra version 10.13) for Xcode

Downloaded Command Line Tools (macOS High Sierra version 10.13) for Xcode

Installing Command Line Tools (macOS High Sierra version 10.13) for Xcode

Done with Command Line Tools (macOS High Sierra version 10.13) for Xcode

Done.

==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

Password:

==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

==> Downloading and installing Homebrew...

HEAD is now at dae47914 Merge pull request #4992 from MikeMcQuaid/keg-remove-top-level-directories

==> Migrating /Library/Caches/Homebrew to /Users/galahad/Library/Caches/Homebrew

==> Deleting /Library/Caches/Homebrew...

Already up-to-date.

==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.

Read the analytics documentation (and how to opt-out) here:

  https://docs.brew.sh/Analytics.html

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:

  https://github.com/Homebrew/brew#donations

==> Next steps:

- Run `brew help` to get started

- Further documentation: 

  https://docs.brew.sh

接下来可使用Homebrew来安装 Node 和 Watchman等工具了。

相关文章
相关标签/搜索