使用Homebrew来安装Node等工具
原文转载自:https://www.cnblogs.com/richard-youth/p/9718349.html
使用 React Native,必须安装的依赖有:Node、Watchman 和 React Native 命令行工具以及 Xcode。
推荐使用 Homebrew 来安装 Node 和 Watchman。
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 node
卸载软件,如:brew uninstall node
搜索软件,如:brew search node
更新软件,如:brew upgrade node
查看安装列表,如: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这个工具。
6、详细的流程:
$ 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等工具了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现