美文网首页
React Native 环境搭建 遇到的错误整理

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

作者: 南山青稞酒 | 来源:发表于2016-09-24 13:07 被阅读841次

    环境搭建

    • <a href = "https://facebook.github.io/react-native/releases/next/docs/getting-started.html#content">官网</a>

    • <a href = "http://bbs.reactnative.cn/category/2/讨论区">中文社区</a>

    • <a href= "https://github.com/coolnameismy/dev-tips">研究中的 github</a>
    • 错误0

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

    </span>
    <a href = "https://segmentfault.com/a/1190000005900586">传送门</a>

    • 错误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 : 
    
    <key>NSAppTransportSecurity</key>
    <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    </dict>
    
    
    * ##错误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以上的版本

    <span>

    • 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(项目名称)
      </span>
      <a href = "http://www.cnblogs.com/Don/p/4672287.html">传送门1</a>
      <a href = "http://www.jianshu.com/p/078d9900a7c8">传送门2</a>

    • 错误4

      项目init 成功 但是无读写权限

      解决办法:

      <a href = "http://blog.csdn.net/lizitao/article/details/39475103">传送门<a>

    相关文章

      网友评论

          本文标题:React Native 环境搭建 遇到的错误整理

          本文链接:https://www.haomeiwen.com/subject/nyexyttx.html