fix(cli): resolve bin path from cwd to support monorepo workspace hoisting#7315
Open
Aaron3312 wants to merge 1 commit intorefinedev:mainfrom
Open
fix(cli): resolve bin path from cwd to support monorepo workspace hoisting#7315Aaron3312 wants to merge 1 commit intorefinedev:mainfrom
Aaron3312 wants to merge 1 commit intorefinedev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 15ce85f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
alicanerdurmaz
requested changes
Mar 4, 2026
Member
alicanerdurmaz
left a comment
There was a problem hiding this comment.
Hi, thanks for improving Refine.
Everything looks great except changeset file names should be auto-generated.
…sting
When using npm/bun/yarn workspaces, packages are hoisted to a parent
node_modules. The previous require.resolve('.bin/<name>') resolved
relative to the CLI module location, which fails when the CLI is
installed in a different node_modules subtree than the project binaries.
resolveBin() now walks up from process.cwd() searching each
node_modules/.bin/ until the binary is found, falling back to the
original require.resolve behavior for backward compatibility.
On Windows, both .exe and .cmd extensions are checked.
Fixes refinedev#7314
a27a555 to
15ce85f
Compare
Author
|
Thanks for the review! I've renamed the changeset file to an auto-generated name ( |
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.
PR Checklist
Bugs / Features
What is the current behavior?
When running
refine devinside a monorepo workspace (npm workspaces, yarn workspaces, or Bun), the CLI crashes with:resolveBin()usedrequire.resolve('.bin/<name>')which resolves relative to the CLI module's own location insidenode_modules. In a workspace setup, the CLI lives in a differentnode_modulessubtree than the project binaries (e.g.vite), so the binary is never found.What is the new behavior?
resolveBin()now walks up the directory tree starting fromprocess.cwd(), checking eachnode_modules/.bin/<name>until the binary is found. This correctly handles the workspace hoisting case where the binary lives in a parent directory'snode_modules/.bin/.On Windows, both
.exeand.cmdextensions are checked. The originalrequire.resolvebehavior is kept as a fallback for backward compatibility.fixes #7314
Notes for reviewers
The fix is minimal and contained entirely in
packages/cli/src/commands/runner/projectScripts.ts. Three new tests covering the standard and monorepo scenarios were added toprojectScripts.test.ts.