mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #121] [CLOSED] fix(deploy): resolve node_modules by walking up to monorepo root #329
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#329
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/121
Author: @harrisrobin
Created: 2/26/2026
Status: ❌ Closed
Base:
main← Head:fix/monorepo-node-modules-resolution📝 Commits (4)
dd656fechore: add .worktrees/ to .gitignorebf3a90efix(deploy): detect bun.lock text format and walk up to monorepo roota5875a1fix(routing): pass exclude as function to node:fs/promises.globcb6c314fix(deploy): resolve node_modules by walking up to monorepo root📊 Changes
6 files changed (+198 additions, -27 deletions)
View changed files
📝
.gitignore(+3 -0)📝
packages/vinext/src/deploy.ts(+13 -15)📝
packages/vinext/src/routing/app-router.ts(+7 -3)📝
packages/vinext/src/routing/pages-router.ts(+7 -1)📝
packages/vinext/src/utils/project.ts(+67 -8)📝
tests/deploy.test.ts(+101 -0)📄 Description
Problem
vinext deployfails in monorepos with an ENOENT crash when the wrangler binary is hoisted to the workspace root rather than installed in the app's ownnode_modules:Three separate places hardcode
path.join(root, "node_modules", ...)and fail to find hoisted packages:detectProject—hasCloudflarePlugin,hasRscPlugin,hasWranglerall check the app-levelnode_modulesonly, producing false negatives for all three in a monorepo.getMissingDeps—hasMdxRolluphas the same issue.runWranglerDeploy— constructs the wrangler binary path from the app root, crashing with ENOENT when the binary is at the workspace root.The false negatives in (1) and (2) also cause vinext to try to re-install packages that are already present, adding unnecessary install steps.
Fix
Add
findInNodeModules(start, subPath)toutils/project.ts— it walks up parent directories until it findsnode_modules/{subPath}, returning the absolute path ornull. This mirrors the same approach already used for lock file detection indetectPackageManager.All four callsites are updated to use it:
Tests
5 new unit tests for
findInNodeModules:pnpm run typecheckandpnpm run lintpass clean./bonk
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.