fix(install_node_modules): detect package manager from workspace root#3553
Open
PHILLIPS71 wants to merge 1 commit intoexpo:mainfrom
Open
fix(install_node_modules): detect package manager from workspace root#3553PHILLIPS71 wants to merge 1 commit intoexpo:mainfrom
PHILLIPS71 wants to merge 1 commit intoexpo:mainfrom
Conversation
|
Subscribed to pull request
Generated by CodeMention |
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.
Why
In pnpm and bun monorepos,
eas/install_node_modulesincorrectly falls back to yarn even when apnpm-lock.yamlexists at the workspace root.resolvePackageManageris called with the app's working directory (apps/app) beforefindPackagerRootDirhas located the workspace root. Since@expo/package-managerdetects the package manager via lockfiles, and the lockfile lives at the monorepo root rather than the app subdirectory, no package manager is detected and the function defaults to yarn.findPackagerRootDirthen correctly resolves the monorepo root, but by that point yarn has already been chosen and is invoked from there.The obvious workaround of adding a
packageManagerfield to the app's ownpackage.jsondoes not work becauseresolvePackageManagerdoes not read this field. Yarn is still invoked and then errors when it encounters the field value:The only working solution today is a custom build workflow that replaces
eas/install_node_modulesentirely.How
Swap the order of
resolvePackageManagerandfindPackagerRootDirso the package manager is detected from the workspace root, where the lockfile actually lives.If no workspace root is found,
findPackagerRootDirreturns the working directory unchanged, so behaviour for non-monorepo projects is identical.Test Plan
Reproduction:
pnpm-workspace.yamlandpnpm-lock.yamlat the rootapps/app) without its own lockfileeas buildand observe EAS invokingyarn installAfter the fix:
findPackagerRootDirresolves the monorepo rootresolvePackageManagerfindspnpm-lock.yamlthere and correctly selects pnpmpnpm install --frozen-lockfileruns from the monorepo root and succeeds