React|React Native 环境搭建 遇到的错误整理

环境搭建

  • 官网
  • 中文社区
  • 研究中的 github
  • 错误0

###解决方法:手动设置IP- RCTBundleURLProvider在接口中暴露了jsLocation属性,可以通过setJsLocation手动设置IP。``` NSURL *jsCodeLocation; [[RCTBundleURLProvider sharedSettings] setDefaults]; #if DEBUG [[RCTBundleURLProvider sharedSettings] setJsLocation:@"192.168.1.101"]; #endif jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];


传送门
  • 错误1

    2016-09-24 10:57:56.432 [warn][tid:main][RCTEventEmitter.m:54] Sending websocketFailed with no listeners registered.
    2016-09-24 10:57:56.471 [info][tid:com.facebook.react.JavaScript] Running application "HelloWorld" with appParams: {"rootTag":1,"initialProps":{}}. DEV === true, development-level warning are ON, performance optimizations are OFF

解决方法:
本地服务器未启动 sudo npm start
  • 错误2

    2016-09-24 11:01:14.620 HelloWorld[56128:350791] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
###解决方法: 禁用https :

NSAppTransportSecurity NSAllowsArbitraryLoads

* ##错误3 >``` You are currently running Node v0.12.0 but React Native requires >=4. Please use a supported version of Node. See https://facebook.github.io/react-native/docs/getting-started.html

解决方法:
安装一个nvm,通过nvm安装一个nodejs4.0以上的版本

  • 【React|React Native 环境搭建 遇到的错误整理】brew install nvm
  • vim bash_profile 添加自动启动
    • export NVM_DIR=~/.nvm
    • source $(brew --prefix nvm)/nvm.sh
  • source bash_profile
  • nvm install v4.2.4
  • sudo react-navtive init HelloWorld(项目名称)

    传送门1
    传送门2
  • 错误4 项目init 成功 但是无读写权限 解决办法:
    传送门

    推荐阅读