Fix CLI_PATH resolution when @expo/cli is nested inside expo/node_modules#85
Open
pkelecom wants to merge 1 commit intobndkt:mainfrom
Open
Fix CLI_PATH resolution when @expo/cli is nested inside expo/node_modules#85pkelecom wants to merge 1 commit intobndkt:mainfrom
pkelecom wants to merge 1 commit intobndkt:mainfrom
Conversation
…ules
In projects using Expo SDK 50+, @expo/cli is no longer installed at the
root node_modules level — it lives inside expo/node_modules/@expo/cli.
The previous require.resolve('@expo/cli') call fails with
"Cannot find module '@expo/cli'", causing the App Clip bundle phase to
fall back to the legacy React Native bundler which lacks support for path
aliases (e.g. @/ imports).
This uses the same resolution strategy that Expo already generates for
the main app target: passing a paths option so Node resolves @expo/cli
relative to the expo package, regardless of hoisting.
Before:
export CLI_PATH="$($NODE_BINARY --print "require.resolve('@expo/cli')")"
After: export CLI_PATH="$($NODE_BINARY --print "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })")"
Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
|
@pkelecom Could you clarify which Expo version and package installer you're encountering this issue on? Additionally, I believe the proposed fix here may cause breaking changes depending on hoisting behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In projects using Expo SDK 50+,
@expo/cliis no longer hoisted to the rootnode_modules— it lives insideexpo/node_modules/@expo/cli. The App Clip bundle phase script usedrequire.resolve('@expo/cli')which fails with:This causes the build to silently fall back to the legacy React Native bundler (
react-native-xcode.shwith its own CLI), which doesn't understand path aliases like@/imports configured via Metro. The result is a confusing secondary error:Fix
Use the same resolution strategy that Expo already generates for the main app target — passing a
pathsoption so Node can find@expo/clirelative to theexpopackage, regardless of hoisting:Before:
After:
Impact
This affects any project using
react-native-app-clipwith Expo SDK 50+ that does not have@expo/clilisted as a direct dependency inpackage.json. The fix is consistent with how Expo itself resolves the CLI in the main target's bundle phase.Made with Cursor