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

React Native 0.64.3安装expo-barcode-scanner遇ExpoBarCodeScanner模块找不到错误求助

解决React Native 0.64.3中expo-barcode-scanner模块找不到的问题

1. 对齐unimodules与依赖包版本

你的核心问题是unimodules版本(0.11.0)与React Native 0.64.3不兼容,导致模块适配失败。需统一升级到适配版本:

  • 卸载冲突包:
    npm uninstall expo-barcode-scanner @unimodules/react-native-adapter @unimodules/core
    
  • 安装匹配版本(expo-barcode-scanner 11.x适配RN 0.64.x与unimodules 0.13.x):
    npm install expo-barcode-scanner@11.2.0 @unimodules/react-native-adapter@0.13.3 @unimodules/core@0.13.3
    

2. 确认原生模块配置

RN 0.64.x支持自动链接,但需确保unimodules配置正确:

  • iOS:进入ios目录,执行pod install --repo-update。若Podfile未配置unimodules,需在开头添加:
    require_relative '../node_modules/@unimodules/core/scripts/autolinking'
    require_relative '../node_modules/expo-barcode-scanner/scripts/autolinking'
    
    再重新执行pod install
  • Android:检查android/settings.gradle是否包含:
    apply from: '../node_modules/@unimodules/core/scripts/settings.gradle'
    includeUnimodulesProjects()
    
    并确认android/app/build.gradle的dependencies中存在:
    implementation project(':unimodules-core')
    implementation project(':expo-barcode-scanner')
    

3. 清除缓存并重建项目

  • 清除Node缓存:
    npm cache clean --force
    
  • 重置RN缓存:
    npx react-native start --reset-cache
    
  • 重新构建项目:
    • iOS:npx react-native run-ios --clean
    • Android:npx react-native run-android --clean

4. 排查额外问题

  • 确认项目为bare workflow(原生RN项目),managed workflow无需手动处理unimodules
  • 所有@unimodules/*包必须保持同一主版本号,禁止混合版本
  • 在app.json/app.config.js中添加插件配置:
    {
      "expo": {
        "plugins": ["expo-barcode-scanner"]
      }
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 16:25:08