react-native 环境搭建

今天在做react native ,遇到了不少问题,最郁闷的是官方的react native是有bug,造成了启动成功后,通过url报错误,Unable to resolve module 'AccessibilityInfo', when trying to create release bundle

  1. http://bbs.reactnative.cn/topic/10/%E5%9C%A8windows%E4%B8%8B%E6%90%AD%E5%BB%BAreact-native-android%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83

和https://reactnative.cn/docs/getting-started.html中的方法做

  1. 安装java jdk 然后配置JAVA_HOME 和path  我安装了1.8
  2. 安装android studio2.2.3 配置 ANDROID_HOME 和path
  3. 下载git 和nodejs 我的版本 node-v8.11.3-x64.msi  Git-2.18.0-64-bit.exe  安装
  4. 配置npm 镜像

npm config set registry https://registry.npm.taobao.org --global

 

npm config set disturl https://npm.taobao.org/dist --global

  1. 安装react-native命令行工具

npm install -g react-native-cli

  1. 创建项目

react-native init MyProject

  1. 启动react-native

Cd MyProject   react-native start

至此都ok,但是 运行http://localhost:8081/index.bundle?platform=android,则报错

Unable to resolve module 'AccessibilityInfo', when trying to create release bundle

  1. 看了官方给的方法,什么删除npm 什么这个那个的,都不行,后来看了国外网站的帖子,说native0.56有问题,不能使用,只能使用老版本
  2. React-native -v 一看版本就是0.56的,不能用

npm uninstall -g react-native-cli

npm uninstall react-native

 

npm install react-native@0.55.4

npm install -g react-native-cli@1.2.0

react-native init --version="0.55.4" myprojectname

需要注意的是 建立工程的时候必须是带着版本,否则还是0.56

React-native start

npm config set disturl https://npm.taobao.org/dist --global

http://localhost:8081/index.bundle?platform=android

看到了久违的页面了

  1. react-native run-android 遇到gradle-2.14.1-all.zip慢的问题

打开E:\working\reactnative\myprojectname\android\gradle\wrapper\gradle-wrapper.properties

把最后的https\://services.gradle.org/distributions/gradle-2.14.1-all.zip放到浏览器中下载

,下载完毕后,更改为distributionUrl=file\:///E:/wangzg/download/software/gradle/gradle-2.14.1-all.zip

cmd:

react-native start

先启动虚拟机

react-native run-android

就把gradle-2.14.1-all.zip启动了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值