React开发笔记(一) 环境搭建和Hello World

1 安装

安装brew

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

修复/usr/local权限

1
sudo chown -R `用户名` /usr/local

安装node.js,进https://nodejs.org/en/下载安装包安装,装好后进终端输入node -v查看版本。

设置npm镜像源

1
2
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

安装yarn

1
npm install -g yarn react-native-cli

设置yarn镜像源

1
2
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

安装Watchman

1
brew install watchman

开启gradle daemon

1
touch ~/.gradle/gradle.properties && echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties

设置安卓SDK路径

1
vi ~/.bash_profile

添加

1
export ANDROID_HOME=~/Library/Android/sdk

1
source ~/.bash_profile

测试

进入要放置项目的目录

1
2
3
react-native init ReactTest
cd ReactTest
react-native run-android
如果您觉得这篇文章不错,可以打赏支持下哦,谢谢