您的位置:首页 > Web前端 > React

React Native环境搭建

2016-12-14 02:01 323 查看
按步骤在终端执行以下命令即可

1、安装Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"[/code] 

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
验证是否安装成功
brew -v


2、安装 npm 和 Node.js
brew install node


3、安装 React Native
npm install -g yarn react-native-cli


(sudo)npm install -g react-native-cli

4、安装 WatchMan

brew link autoconf

brew link automake
brew install watchman


5、安装 Flow
brew install flow


6、配置镜像
npm config set registry https://registry.npm.taobao.org npm config set disturl https://npm.taobao.org/dist[/code] 
7、生成工程

react-native init 项目名称 


react-native init 项目名称 --verbose


8、其他

(1)查看本地的React Native的版本 
react-native --version
(2)更新本地的React Native的版本
npm update -g react-native-cli
(3)查询react-native的npm包最新版本 
npm info react-native
(4)更新项目中的RN

先要进到项目中cd /Users/targetcloud/Desktop/RN/AHelloworld  然后
react-native upgrade


9、安装过程中的错误提示

(1)sudo chown -R `whoami` /usr/local 或 
sudo chown -R $(whoami):admin /usr/local
Error: Could not link:

/usr/local/etc/bash_completion.d/brew

Please delete these paths and run `brew update`.

Error: Could not link:

/usr/local/share/doc/homebrew

Please delete these paths and run `brew update`.

Error: Could not link:

/usr/local/share/zsh/site-functions/_brew

Please delete these paths and run `brew update`.

Error: Could not link:

/usr/local/share/man/man1/brew-cask.1

/usr/local/share/man/man1/brew.1

targetclouddeMacBook-Pro:~ targetcloud$ brew update

Already up-to-date.

(2)在brew install watchman之前先执行brew link autoconf和brew link automake

Error: You must `brew link autoconf automake` before watchman can be installed

targetclouddeMacBook-Pro:~ targetcloud$ brew link autoconf

Linking /usr/local/Cellar/autoconf/2.69... 48 symlinks created

targetclouddeMacBook-Pro:~ targetcloud$ brew link automake
Linking /usr/local/Cellar/automake/1.15... 113 symlinks created

targetclouddeMacBook-Pro:~ targetcloud$ brew install watchman



参考
http://reactnative.cn/docs/0.38/getting-started.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  RN React-Native