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

Ubuntu下无法创建React Native项目及Expo初始化失败求助

解决方案

Ubuntu下React Native初始化失败(yarn版本解析错误、退出码243)

  • 强制使用npm初始化项目,绕过yarn检测:
    npx react-native init MyRNProject --npm
    
  • 验证yarn安装与环境变量:
    1. 执行yarn --version,若报错则说明yarn未正确加入系统PATH
    2. 查找yarn全局安装路径:npm list -g yarn,提取路径下的bin目录(如/home/xxx/.npm-global/bin)
    3. 将该路径添加到~/.bashrc或~/.zshrc:export PATH="$PATH:/你的yarn/bin路径",执行source ~/.bashrc生效
  • 调整yarn版本到兼容版:
    npm uninstall -g yarn
    npm install -g yarn@1.22.19
    

Expo创建项目找不到模板问题

  • 清理缓存后重新指定模板执行:
    npm cache clean --force
    npx create-expo-app MyExpoProject --template blank@latest
    
  • 临时使用国内镜像源拉取模板:
    npx create-expo-app MyExpoProject --template blank@latest --registry=https://registry.npmmirror.com
    
  • 全局安装create-expo-app后创建项目:
    npm install -g create-expo-app
    create-expo-app MyExpoProject --template blank@latest
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 05:12:36