因为小编是iOS开发,在这里我只介绍关于Mac环境和iOS开发,请大家谅解。
前期因为版本太快,需要随时更新,这里给出官方文档地址
http://facebook.github.io/react-native/docs/getting-started.html
中文地址 http;//reactnative.cn/docs/getting-started.html#content.
第一步:安装Xcode,这里不再描述,AppStore可以下载。
下来我们进入命令行终端。
第二步:安装Homebrew。ruby -e "$(curl -fsSl https://raw.githubusercontent.com/Homebrew/install/master/install)" 此安装命令需要输入密码。之后等待出现“Installation successful!”.
第三步:安装Node.js。进入https://nodejs.org。安装最新稳定版本的node.js。
第四步:安装NVM,在命令行终端输入 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash 或者 wget -qO-https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
安装完成后,在命令行窗口可能会显示:
Checking connectivity... done.
* (HEAD detached at v0.30.1)
master
=> Profile not found. Tried (as defined in $PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc,and ~/.profile.
=> Create one of them and run this script again
=> Create it (touch) and run this script again
OR
=> Append the following lines to the corrent file yourself:
export NVM_DIR="/User/你的用户名/.nvm"
[-s "$NVM_DIR/nvm.sh"] && ."$NVM_DIR/nvm.sh" #This loads nvm
=> Close and reopen your terminal to start using nvm
如果出现了提示,复制倒数第三局和倒数第二句话。输入:vi .bash_profile 在出现的编辑窗口中按i键,直接黏贴刚才复制的语句,单后按Esc键,再输入":wq",按回车。接着退出命令行终端。
重新打开命令行终端输入 echo $NVM_DIR 如果命令行出现:/Users/你的用户名/.nvm。说明修改正确,NVM正确安装。然后在输入 nvm install node && nvm alias default node。
第五步:安装flow软件包。先输入
sudo chown -R $USER /usr/local/lib
sudo chown -R $USER /usr/local
接下来在输入
brew install watchman
brew install flow
第六步:安装React Native。输入
sudo npm install -g react-nactive-cli
需要输入密码,完成安装
第七步:安装Sublime Text 3。访问www.sublimetext.com/3 下载SublimeText 3安装包进行安装。关于其他的插件,请自行百度,谷歌安装。
到此,我们的基本环境已经搭建完毕。