fix(core): Resolve expo CLI directly instead of using npx in sourcemap upload#6155
Conversation
…p upload
Replace `npx expo config --json` with direct `require.resolve('expo/bin/cli')`
to avoid npm's `devEngines.packageManager` enforcement breaking the script
for projects that restrict their package manager to pnpm or yarn.
Fixes #6152
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 1 more 🤖 This preview updates automatically when you update the PR. |
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exercises the `require.resolve('expo/bin/cli', { paths: [process.cwd()] })`
fallback path used in pnpm/yarn PnP environments where expo is not
resolvable from the script's own location.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
q: the auto-generated PR description has the claim that yarn PnP works but how could it be since the whole PR depends on the existance of |
| const mockNpxScript = path.join(mockBinDir, 'npx'); | ||
| // The mock npx script outputs the config JSON when called with 'expo config --json' | ||
| // Create a mock expo/bin/cli that outputs the given expo config as JSON | ||
| const mockExpoCliDir = path.join(tempDir, 'node_modules', 'expo', 'bin'); |
There was a problem hiding this comment.
expo/bin/cli is not a public API — ok, it works today but if Expo renames/relocates it, sourcemap upload will silently fall back to sentry.properties/env vars
There was a problem hiding this comment.
what I'm saying is that it's probably better to resolve expo/package.json and read its bin.expo field
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of hardcoding `expo/bin/cli`, resolve `expo/package.json` and read its `bin.expo` field to construct the CLI path. This is resilient to Expo renaming or relocating the bin entry point. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Good point @alwx 👍 I've updated the PR description. Ready for another pass |
📲 Install BuildsAndroid
|
📢 Type of change
📜 Description
Replaces
spawnSync('npx', ['expo', 'config', '--json'])in@sentry/expo-upload-sourcemapswith direct module resolution viarequire.resolve('expo/package.json'), reading thebin.expofield from it, and spawning the resolved CLI path withprocess.execPath.This avoids going through npm/npx entirely, which prevents npm's
devEngines.packageManagerenforcement from rejecting the call when the project restricts its package manager to pnpm.The resolution tries two paths:
require.resolvefrom the script's location (works with hoisted layouts — npm, yarn classic)require.resolvewithpaths: [process.cwd()](works with strict isolation — pnpm)If neither resolves, the existing fallback chain (
sentry.properties→ env vars) kicks in unchanged.💡 Motivation and Context
Projects using npm v11+'s
devEngines.packageManagerfield to enforce pnpm getEBADDEVENGINESwhen the sourcemap upload script internally callsnpx expo config --json, because npm detects the package manager mismatch and refuses to run.Fixes #6152
💚 How did you test it?
devEngines.packageManager: pnpm, confirmednpx expo config --jsonfails withEBADDEVENGINESsamples/expoproject — identical behavior to the old approach📝 Checklist
sendDefaultPIIis enabled🔮 Next steps