react-native环境配置

本章注意记录了Mac下配置react-native开发环境

1.首先需要安装Homebrew.打开终端输入以下安装命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

若命令行提示,表示Homebrew已经安装过,你需要先移除xxx之类的东西,参考。

安装Homebrew失败

卸载之前安装的版本

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
react-native环境配置_第1张图片
移除Homebrew成功

卸载命令执行完成之后,还有些缓存文件需要删除,这时手动即可。

/usr/local/.DS_Store
/usr/local/.git/
/usr/local/bin/
/usr/local/include/
/usr/local/lib/
/usr/local/share/

有隐藏文件,这里推荐一个命令。隐藏or展示系统隐藏文件

显示:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false

删除完成之后,再执行第一步的安装命令,即可成功安装Homebrew环境。

react-native环境配置_第2张图片
安装Homebrew成功

2.安装Node.js

React Native 借助 Node.js,即 JavaScript 运行时来创建 JavaScript 代码。如果你已经安装了 Node.js,那就可以上手了。
打开终端,执行使用Homebrew安装Node.js的安装命令

brew install node
react-native环境配置_第3张图片
安装node成功
3.安装watchman

一个来自Facebook 的观察程序

brew install watchman

通过配置 watchman,React 实现了在代码发生变化时,完成相关的重建的功能。就像在使用 Xcode 时,每次保存文件都会进行一次创建。
This is used by React Native to figure out when your code changes and rebuild accordingly. It’s like having Xcode do a build each time you save your file.

react-native环境配置_第4张图片
安装watchman成功
4.通过Node.js安装React Native CLI工具
npm install -g react-native-cli

这使用 Node 包管理器抓取 CLI 工具,并且全局安装;npm 在功能上与 CocoaPods 或者 Carthage 类似。
This uses the Node Package Manager to fetch the CLI tool and install it globally; npm is similar in function to CocoaPods or Carthage.

react-native环境配置_第5张图片
React Native CLI工具安装成功

到此为止,Mac上的react-native环境已经配置完成。

你可能感兴趣的:(react-native环境配置)