官方学习网站:http://facebook.github.io/react-native/docs/getting-started.html
http://reactnative.cn/docs/0.43/getting-started.html
node.js:http://www.nodebeginner.org/index-zh-cn.html
ReactNative的环境搭建是开始ReactNative的第一步,但是对新手其中会遇到很多的问题,经过自己的搭建过程,记录下一些坑
首先我们可以参考http://reactnative.cn/docs/0.43/getting-started.html
上的步骤进行
1 安装Homebrew
Homebrew, Mac系统的包管理器,用于安装NodeJS和一些其他必需的工具软件。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" sudo chown -R
whoami/usr/local
2 安装node
brew install node
系统会默认安装一份node,所以我们自己安装的node的过程中会报not linked的错误
brew link –overwrite note
(在这个问题上浪费了很长时间)
安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)。注意:不要使用cnpm!cnpm安装的模块路径比较奇怪,packager不能正常识别!
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
3 安装Yarn、React Native的命令行工具(react-native-cli)
npm install -g yarn react-native-cli
安装完yarn后同理也要设置镜像源:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
推荐安装的工具
Watchman
Watchman是由Facebook提供的监视 件系统变 的 具。安装此 具可以提 开发时的性能(packager 可以快速捕捉 件的变化从 实现实时刷新)。
brew install watchman
Flow
Flow是 个静态的JS类型检查 具。译注:你在很多示 中看到的奇奇怪怪的冒号问号,以及 法参数中|
像类型 样的写法,都是属于这个flow 具的语法。这 语法并 属于ES标准,只是Facebook 家的代 码规范。所以新 可以直接跳过(即 需要安装这 具,也 建议去费 学习flow相关语法)
brew install flow
网友评论