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

升级pnpm至11.5.2后Expo Doctor报错:模块目录Android/iOS被Git忽略

pnpm升级后Expo Doctor检测到本地模块android/ios目录被忽略问题

问题背景

将pnpm从10.22版本升级至11.5.2版本后,Expo Doctor出现此前未有的检查失败提示。项目为monorepo结构:

/app
/shared
/web

Expo Doctor报错信息

18/19 checks passed. 1 checks failed. Possible issues detected:
Use the --verbose flag to see more details about passed checks.
✖ Check for common project setup issues
The "android" and/or "ios" directories (./modules/your-module/[android|ios])
for local Expo modules are gitignored, and they should not be. This is often
due to overly general gitignore rules.
Advice:
Use patterns like "/android" and "/ios" in your .gitignore file to exclude
only the top-level "android" and "ios" directories, and not those in the
modules directory.
1 check failed, indicating possible issues with the project.

各层级.gitignore内容

根目录.gitignore

# dependencies
node_modules/

# local task/worktree scratch files
.ji/

# Expo
.expo/
dist/
dist-test/
web-build/
expo-env.d.ts

# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local
.settings.local.*

# typescript
*.tsbuildinfo
playwright/
test-results

# Turborepo
.turbo

# App builds
app/ios
app/android

# Security reports
.ash/

# Git worktrees
.worktrees/

app目录.gitignore

# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli

expo-env.d.ts
# @end expo-cli

.claude/settings.local.json

app/modules/[my-module]目录.gitignore

build/
**/build/
*.iml

问题原因与解决方法

原因分析

  1. Expo Doctor检查逻辑升级:pnpm升级后,关联的Expo Doctor版本同步更新,对本地Expo模块的版本控制校验变得更严格,开始强制要求模块内的android/ios目录必须被Git跟踪,不能被忽略。
  2. Gitignore规则存在潜在风险:你的根目录.gitignore中仅指定了忽略app/ios和app/android,但没有明确声明不忽略app/modules/*/android和app/modules/*/ios目录。虽然当前没有直接忽略这些模块目录的规则,但Expo Doctor判定这种“未明确允许”的状态属于过度宽泛的忽略风险,因此触发报错。

对应规则说明

目前你的.gitignore中没有直接导致模块内android/ios被忽略的条目,问题源于规则的不完整性——缺少对模块目录的明确放行规则,加上Expo Doctor新的校验逻辑,才出现了这个之前未被检测到的提示。

解决方案

在根目录.gitignore中添加以下规则,明确允许模块内的android/ios目录被Git跟踪:

# 放行本地模块的android/ios目录,避免被忽略
!app/modules/*/android/
!app/modules/*/ios/

如果你的项目根目录存在顶级的android/ios目录需要忽略,也可以按照Expo的建议,将顶级目录的忽略规则改为根路径限定形式:

# 仅忽略根目录下的android/ios目录,不影响模块内的同名目录
/android/
/ios/

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.11 09:04:51