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

Expo 46与React Native 0.69.6下无法解析@unimodules/core模块问题

解决Expo 46中@unimodules/core模块找不到的错误

问题描述

出现以下模块解析错误:

Unable to resolve module @unimodules/core from D:\react-native-tutorial\node_modules\expo-gl\build\GLView.js: @unimodules/core could not be found within the project or node_modules

尽管Expo 43版本后官方已整合相关模块,但使用Expo 46时仍遇到此问题,当前项目的package.json配置如下:

{
  "name": "react-native-tutorial",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/stack": "^6.3.2",
    "@tensorflow/tfjs": "^4.0.0",
    "@tensorflow/tfjs-react-native": "^0.8.0",
    "base-64": "^1.0.0",
    "expo": "~46.0.13",
    "expo-asset": "^8.6.1",
    "expo-camera": "~12.3.0",
    "expo-image-picker": "~13.3.1",
    "expo-status-bar": "~1.4.0",
    "firebase": "^9.6.11",
    "react": "18.0.0",
    "react-native": "0.69.6",
    "react-native-gesture-handler": "~2.5.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-reanimated": "~2.9.1",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "~3.15.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

问题原因

Expo 44及以上版本已用expo-modules-core替代了旧的@unimodules/core,但项目中依赖的@tensorflow/tfjs-react-native@0.8.0可能引用了仍依赖@unimodules/core的旧版expo-gl,导致模块找不到。

解决方案

  • 安装官方替代模块expo-modules-core

    expo install expo-modules-core
    
  • 清除项目缓存,避免旧缓存干扰

    expo r -c
    
  • (可选)若上述步骤无效,升级@tensorflow/tfjs-react-native到适配Expo 46的版本,旧版本可能存在兼容性问题

    npm install @tensorflow/tfjs-react-native@latest
    

内容的提问来源于stack exchange,提问作者benwl

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 22:35:56