美文网首页
搭建Mac系统下的React Native开发环境

搭建Mac系统下的React Native开发环境

作者: henu_Larva | 来源:发表于2017-04-25 14:44 被阅读7次

本文的搭建过程只针对 Mac 系统下,其他系统的搭建请参考以下链接:

http://reactnative.cn/docs/0.43/getting-started.html

注:本文亦是参考上面的链接的总结概括.权作记录.

1.打开终端
2.安装 Homebrew,Homebrew是Mac系统的包管理器,用于安装NodeJS和一些其他必需的工具软件。

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

注:在Max OS X 10.11(El Capitan)版本中,homebrew在安装软件时可能会碰到/usr/local目录不可写的权限问题。可以使用下面的命令修复:

sudo chown -R `whoami` /usr/local

3.使用Homebrew来安装Node.js.

brew install node

4.安装完 NodeJS后在终端内输入下面两条语句:

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

5.安装 Yarn,Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载

npm install -g yarn react-native-cli

6.安装Yarn后在终端内输入下面两条语句:

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

若遇到权限问题,则输入下面的语句:

sudo chown -R `whoami` /usr/local

7.安装 Watchman,Watchman是由Facebook提供的监视文件系统变更的工具。安装此工具可以提高开发时的性能(packager可以快速捕捉文件的变化从而实现实时刷新)。

brew install watchman

8.至此安装完毕,测试下吧:

react-native init 你的项目名称
cd 你的项目名称
react-native run-ios

9.推荐使用WebStormSublime Text来编写React Native应用。

相关文章

网友评论

      本文标题:搭建Mac系统下的React Native开发环境

      本文链接:https://www.haomeiwen.com/subject/dgevzttx.html