Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React-Native环境搭建 #2

Open
hufeng opened this issue Nov 24, 2015 · 2 comments
Open

React-Native环境搭建 #2

hufeng opened this issue Nov 24, 2015 · 2 comments

Comments

@hufeng
Copy link
Owner

hufeng commented Nov 24, 2015

先决条件

目前React-Native的开发环境对Linux和Windows支持的不是特别好,尤其Windows。
另外,xcode是跨不过去的坎。所以,Mac还是必备的。

目前React-Native只支持iOS 7 和 Android 4.1(api 16) +

搭建开发环境

  1. 安装homebrew
  2. 安装Nodejs 4.0 +, 最好是4.2.2是LTS的稳定版本,npm最好使用npm2,npm3目前还不够稳定,速度还比较慢。推荐使用n来进行node的版本管理
  3. 安装watchman,监控文件的变化
brew install watchman
  1. 安装flow,可以对js进行类型的检查
brew install flow

快速安装项目脚手架

npm install -g react-native-cli

创建项目

react-native init AwesomeProj

running iOS

cd AwesomeProj
open ios/AwesomeProj.xcodeproj

running Android

cd AwesomeProj
react-native run-android #或者使用Android Studio

项目结构

➜ CoolApp tree -L 1
.
├── android
├── index.android.js
├── index.ios.js
├── ios
├── node_modules
└── package.json

3 directories, 3 files

android:Android工程目录
iOS: iOS工程目录
node_module:npm的依赖目录
index.android.js: android项目的js入口文件
index.ios.js:ios项目的js入口文件
package.json: 类似mvn的pom.xml文件,定义js的项目依赖

@zhangjin-007
Copy link

第一次安装的时候,一直阻塞npm,配置了淘宝镜像也没有,后来人品爆发才安装好,第一次可以考人家的node_modules解决

@hufeng
Copy link
Owner Author

hufeng commented Nov 24, 2015

@javascala 这个暂时无解,我也试了很多办法,包括我们内部也是搭建了私服。可以拷贝。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants