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

MacOS High Sierra下创建React Native项目时Bundler安装失败求助

React Native项目Bundler安装失败修复方案(MacOS High Sierra)

问题现象

执行 npx react-native init myapp 创建项目时,终端报错:

✔ Downloading template
✔ Copying template
✔ Processing template
✖ Installing Bundler
error 
✖ Installing Bundler
error Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
Error: Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
    at createFromTemplate (/Users/techero/.npm/_npx/1164/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/init/init.js:169:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.initialize [as func] (/Users/techero/.npm/_npx/1164/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/init/init.js:222:3)
    at async Command.handleAction (/Users/techero/.npm/_npx/1164/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:140:9).

运行 npx react-native doctor 检测结果:

Techeros-MacBook-Pro:myapp techero$ npx react-native doctor
Common
 ✓ Node.js
 ✓ npm
 ● Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ JDK
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME

iOS
 ✖ Xcode - Required for building and installing your app on iOS
   - Version found: N/A
   - Version supported: >= 12.x
 ✓ CocoaPods - Required for installing iOS dependencies
 ● ios-deploy - Required for installing your app on a physical device with the CLI
 ✓ .xcode.env - File to customize Xcode environment

Errors:   1
Warnings: 2

Usage
 › Press f to try to fix issues.
 › Press e to try to fix errors.
 › Press w to try to fix warnings.
 › Press Enter to exit.

问题根源

报错核心是iOS环境配置不完整,从检测结果看,最关键的缺失项是Xcode。但MacOS High Sierra(10.13.x)系统最高仅支持Xcode 10.1,无法满足高版本React Native对Xcode≥12.x的要求,这是导致Bundler安装失败的直接原因。

修复步骤

1. 安装适配High Sierra的Xcode版本

High Sierra最高支持Xcode 10.1,可通过以下方式获取安装:

  • 登录Apple ID后,从App Store的已购项目中找到Xcode的历史版本下载
  • 从Apple开发者平台下载对应版本的Xcode安装包

安装完成后,打开Xcode并同意相关协议,完成初始化配置。

2. 配置Xcode命令行工具

打开终端执行命令:

xcode-select --install

若提示已安装,可直接跳过此步骤。

3. 降级React Native版本

选择兼容Xcode 10.1的React Native版本,比如0.63.x系列,执行创建命令:

npx react-native init myapp --version 0.63.4

4. 手动安装Bundler

若项目创建后仍提示Bundler安装失败,进入项目目录手动执行:

cd myapp
gem install bundler
bundle install

5. 解决Watchman和ios-deploy警告(可选)

  • 安装Watchman:
brew install watchman
  • 安装ios-deploy:
npm install -g ios-deploy

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 04:25:18