学习交流:https://gitee.com/potato512/Learn_ReactNative
react-native学习交流QQ群:806870562
- // 安装Homebrew
- /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- // 安装Node.js
- brew install node
- // 设置npm镜像
- npm config set registry https://registry.npm.taobao.org --global
- npm config set disturl https://npm.taobao.org/dist --global
- // 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提供的监视文件系统变更的工具)
- brew install watchman
- // 安装Flow(Flow是一个静态的JS类型检查工具)
- brew install flow
- // 查看当前reactNative版本
- react-native --version
- // 更新全局的reactNative到最新版本
- sudo npm update -g react-native-cli
- // 查看服务器端的reactNative的各版本信息
- npm info react-native
- // 给下载的普通工程下载安装RN环境,根据配置的package.json
- npm install
- // 开启nodejs服务器,客户端可连接下载react js代码,注意debug setting里的ip和端口号分别是电脑 ip:8081
- npm start
- // 根据package.json配置的RN版本,更新RN环境代码
- react-native upgrade
- // 项目降级或升级到指定版本,记得react-native upgrade更新一下项目依赖等
- npm install --save react-native@0.18
已安装有Xcode工具,或Android Studio工具时,使用 react-native init xx命令生成app。
- // 安装某个lib到项目中
- npm install react-native-storage --save
- // 初始化一个工程、下载React Native的所有源代码和依赖包
- react-native init 工程名
- // 运行Android工程(注意:运行时,需要在当前工程目录下)
- react-native run-android
- // 运行IOS工程(注意:运行时,需要在当前工程目录下)
- react-native run-ios
已安装有Xcode工具,或Android Studio工具时,使用create-react-native-app xx命令生成app。