【问题标题】:Expo (react-native) Failed to load all assets on production env (expo start --no-dev -c)Expo (react-native) 无法在生产环境中加载所有资产 (expo start --no-dev -c)
【发布时间】:2023-02-19 03:24:46
【问题描述】:

使用 expo start --no-dev -c 命令运行时在生产环境中出现 Failed to load all assets 错误。错误发生在 iOS 和 Android 上。尝试清除 npm 缓存、metro bundler 缓存。仍然没有运气。无法从论坛或 expo discord 社区找到有效的解决方案。欢迎任何想法/帮助。

package.json如下

"dependencies": {
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/datetimepicker": "6.1.2",
    "@react-native-community/netinfo": "8.2.0",
    "@react-native-masked-view/masked-view": "0.2.6",
    "@react-navigation/bottom-tabs": "^5.11.15",
    "@react-navigation/drawer": "^5.12.9",
    "@react-navigation/native": "^5.9.8",
    "@react-navigation/stack": "^5.14.9",
    "@reduxjs/toolkit": "^1.7.2",
    "date-fns": "^2.23.0",
    "expo": "^45.0.0",
    "expo-camera": "~12.2.0",
    "expo-dev-client": "~1.0.1",
    "expo-device": "~4.2.0",
    "expo-document-picker": "~10.2.1",
    "expo-file-system": "~14.0.0",
    "expo-font": "~10.1.0",
    "expo-image-picker": "~13.1.1",
    "expo-location": "~14.2.2",
    "expo-notifications": "~0.15.4",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "expo-updates": "~0.13.3",
    "formik": "^2.2.9",
    "just-clone": "^3.2.1",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-calendars": "^1.1266.0",
    "react-native-gesture-handler": "~2.2.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.4",
    "react-native-pager-view": "5.4.15",
    "react-native-popup-menu": "^0.15.11",
    "react-native-reanimated": "~2.8.0",
    "react-native-root-toast": "^3.4.0",
    "react-native-safe-area-context": "4.2.4",
    "react-native-screens": "~3.11.1",
    "react-native-svg": "12.3.0",
    "react-native-tab-view": "^2.16.0",
    "react-native-timeline-feed": "^2.0.0",
    "react-native-web": "0.17.7",
    "react-native-webview": "11.18.1",
    "react-redux": "^7.2.6",
    "uuid": "^8.3.2",
    "victory-native": "^35.5.4",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "babel-jest": "^25.2.6",
    "eslint": "^7.32.0",
    "eslint-plugin-react": "^7.25.1",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-react-native": "^3.11.0",
    "jest": "^26.6.3",
    "react-test-renderer": "17.0.1",
    "reactotron-react-native": "^5.0.0",
    "reactotron-redux": "^3.1.3"
  }

【问题讨论】:

    标签: react-native expo production


    【解决方案1】:

    对我来说,我不小心从Text 元素中遗漏了 1 个字符。 在我删除角色后它开始工作。 尝试检查您最近的代码。

    【讨论】:

      【解决方案2】:

      如错误所述,Failed to load all assets,要解决这个有趣的错误,请检查您提供的加载资产的路径并始终添加斜线。

      例如,在 Image 标签的源代码中,我需要加载本地图像,这是一个 LinkedIn 图标。当我这样做时:

               <Image
                source={require("../../../icons/linkedin-icon.png")}
                ...
              />
      

      该应用程序通过该错误。当我在路径的开头添加斜杠时,错误消失了。

      正确的方法如下:

              <Image
                source={require("/../../../icons/linkedin-icon.png")}
                ...
              />
      

      希望这个答案能让你继续前进。祝你好运!

      【讨论】:

        猜你喜欢
        • 2021-06-05
        • 1970-01-01
        • 2020-02-04
        • 2019-08-06
        • 1970-01-01
        • 1970-01-01
        • 2020-03-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多