You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo React Native更新后仅生产环境报Network request failed错误

问题描述

此问题与localhost错误无关。

因平台提示兼容性问题,更新Expo平台及相关库,同时安装最新版Node.js后,项目出现异常。应用通过fetch请求本地数据库获取数据,旧版本运行正常,说明问题不在服务端。

新版本仅在生产环境抛出Network request failed错误,npx expo start开发构建及Expo Go均无异常,推测问题源于版本兼容性,且未使用"localhost"配置。

当前使用版本

  • npm: 10.2.4
  • Node: 20.11.1
  • expo: 6.3.10
  • npx expo version: 0.17.5
  • npx eas --version: eas-cli/7.3.0 win32-x64 node-v17.5.0

相关代码(已隐藏敏感数据)

const localUrl = `http://192.1xx.x.x:xxxx/vent/${valor}`;
const controller = new AbortController();
const signal = controller.signal;
const fetchData = async () => {
    try {
      const response = await fetch(localUrl, { signal: signal });
      if (!response?.ok || !response) {
        console.log("Details:", response);//Android生产环境无法查看此日志
        throw new Error("Error de response: "+ response?.statusText);//此处抛出错误
      }
    }
    //...后续代码包含catch块,调用MyToast(error.message, 10, "error");
}

额外异常

尝试本地运行gradle时,任务因react-native-community_netinfo:androidJdkImage错误无法完成,暂不确定是否与当前问题相关。

内容的提问来源于stack exchange,提问作者Germán

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 18:22:12