Homebrew -- 安装与使用

无论是学习react.js ,还是vue.js 都是需要安装开发环境的,最基本的还是Homebrew,所以首先学会安装Homebrew。

1、Homebrew是什么? 

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

官方网站:点击查看

Git仓库地址:点击查看

2、Homebrew 安装:

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

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

3、Homebrew卸载:

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

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

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

安装软件,如:brew install oclint

卸载软件,如:brew uninstall oclint

搜索软件,如:brew search oclint

更新软件,如:brew upgrade oclint

查看安装列表, 如:brew list

更新Homebrew,如:brew update

5、安装中遇到的问题

(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这个工具。

(2)近日在新的电脑上面安装这个工具的时候遇到的问题,记录下来

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

解决方案:把下面的内容配置到你的host中即可解决

199.232.28.133  raw.githubusercontent.com

最后输入brew -v查看是否正确安装好。

brew -v

Homebrew 2.4.3

Homebrew/homebrew-core (git revision b5f93; last commit 2020-07-03)

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

例如:

brew install telnet安装telnet。

brew install nodejs 或者brew install node安装nodejs,由于新版的nodejs已经集成了npm,所以npm也一并安装好了。同样可以通过输入 "npm -v" 来测试是否成功安装。

node -v

v14.5.0

npm -v

6.14.5

最近使用pod工具,问题频出,类似下面的问题:

fatal: unable to access 'https://github.com/AFNetworking/AFNetworking.git/': Failed to connect to github.com port 443: Operation timed out

尝试重新安装Homebrew等一些列工具的时候,也是有下面的问题:

fatal: unable to access 'https://github.com/Homebrew/brew/': Failed to connect to github.com port 443: Operation timed out

Failed during: git fetch origin --force

修改host文件,但是github.com对应的ip 网上找的都不行,ping不通  ping github.com 不通

只能在https://github.com.ipaddress.com/www.github.com查看对应的真实的ip地址,然后修改host文件即可。如果还出现错误,请多试几次。

posted @ 2018-09-28 14:26  yoowei  阅读(15641)  评论(0编辑  收藏  举报