美文网首页
react native 错误处理

react native 错误处理

作者: 读书有毒不中毒 | 来源:发表于2022-02-26 18:21 被阅读0次

    react-native错误处理--

    1. No bundle URL present
      Make sure you’re running a packager server or have included a .jsbundle file
      (1)ping localhost 如果ping失败
      a.改变host地址
      怎么改? 安装 SwitchHosts,改变localHost地址
      (2)ifconfig查看电脑的ip,替换 localhost
      NSURL * url = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

    NSURL * url = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.wwwReactNative"];

    如果不行,重装cococapod(参考重装cococapod那篇文章)
    删掉node_modules文件夹,重新下载 npm i
    重新进入ios 文件夹,pod install ,然后返回上一个文件夹 yarn ios

    1. Could not connect to development server
      https://blog.csdn.net/baidu_38027860/article/details/93878708
      执行 sudo lsof -i:8081
      ping localhost

    2. GemNotFoundException
      can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
      why 执行何命令导致:pod install
      solution 解决方案:
      先卸载再安装

    gem uninstall cocoapods gem install cocoapods
    详细过程记录(参考重装cococapod文章)

    更新/安装 gem
    gem update --system

    4.listen EADDRINUSE: address already in use :::8081
    (1) 查找占用8081端口的pid

    sudo lsof -i:8081
    

    得到下面

    COMMAND  PID      USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
    node    2800 langapple   25u  IPv6 0xaa0dbc35b2da53d      0t0  TCP *:sunproxyadmin (LISTEN)
    
    

    (2)kill 掉 2800

    sudo kill 2800
    

    (3)检查是否杀死

    sudo lsof -i:8081
    
    1. webview
      (1)报错:react-native-webview could not be found within the project or in these directories: node_modules
      把react-native-webview加载进来
    yarn add react-native-webview
    

    (2) 报错:requireNativeComponent: "RNCWebView" was not found in the UIManager
    a.将RNCWebView 加载到ios pod中

    pod install
    

    b.删掉app
    c.重启app

    yarn ios
    

    相关文章

      网友评论

          本文标题:react native 错误处理

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