react native 错误处理

2022-02-26  本文已影响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
上一篇下一篇

猜你喜欢

热点阅读