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

本地初始化React Native项目遇Bundler安装失败及环境问题

React Native 项目初始化失败解决方案

问题根源

导致初始化失败的两个关键问题:

  • RubyGems版本(3.0.3.1)存在bug,且当前Ruby版本(2.6.10)不满足Gemfile指定的2.7.6版本要求
  • iOS开发环境未完成正确配置

一、修复Ruby与RubyGems版本

  1. 升级RubyGems到指定版本
    执行以下命令:
    gem update --system 3.2.3
    
  2. 安装/切换到Ruby 2.7.6版本
    推荐使用版本管理工具(如rbenv或rvm)来管理Ruby版本:
    • 使用rbenv的操作:
      rbenv install 2.7.6
      rbenv local 2.7.6 # 仅当前项目生效,或用global设置全局版本
      
    • 使用rvm的操作:
      rvm install 2.7.6
      rvm use 2.7.6 --default
      
  3. 重新安装Bundler
    版本适配后安装Bundler:
    gem install bundler
    

二、配置iOS开发环境

完成以下必要配置:

  • 安装Xcode,并确保安装了Command Line Tools(可通过Xcode偏好设置 → Locations 标签页安装)
  • 安装CocoaPods:
    sudo gem install cocoapods
    
  • 验证并设置Xcode命令行工具路径:
    xcode-select --print-path
    
    若路径错误,执行:
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    
  • 接受Xcode许可协议:
    sudo xcodebuild -license accept
    

三、重新初始化项目

完成所有配置后,重新执行初始化命令:

npx react-native init notexpoapp3 --template react-native-template-typescript

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 22:35:24