Skip to content

[wrangler] fix: use unscoped binary name for OpenNext autoconfig commands#12476

Merged
petebacondarwin merged 2 commits intomainfrom
fix/opennext-pnpm-scoped-binary
Feb 10, 2026
Merged

[wrangler] fix: use unscoped binary name for OpenNext autoconfig commands#12476
petebacondarwin merged 2 commits intomainfrom
fix/opennext-pnpm-scoped-binary

Conversation

@MattieTK
Copy link
Member

@MattieTK MattieTK commented Feb 7, 2026

Fixes the wrangler deploy --x-autoconfig failure for Next.js (OpenNext) projects when the package manager is pnpm.

Description

When running wrangler deploy --x-autoconfig on a Next.js project that uses pnpm, the deploy fails because wrangler constructs an invalid build command. The OpenNext migration step completes successfully, but the subsequent build command pnpm @opennextjs/cloudflare build is not valid pnpm syntax.

Root cause

The command overrides in the Next.js autoconfig handler used the scoped package name @opennextjs/cloudflare:

buildCommandOverride: `${npx} @opennextjs/cloudflare build`,
deployCommandOverride: `${npx} @opennextjs/cloudflare deploy`,
versionCommandOverride: `${npx} @opennextjs/cloudflare upload`,

For pnpm, npx resolves to "pnpm" (from PnpmPackageManager), producing pnpm @opennextjs/cloudflare build. pnpm interprets @scope/name as a workspace filter rather than a binary name, failing with:

ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "@opennextjs/cloudflare" not found

Fix

Changed the command overrides to use the unscoped binary name opennextjs-cloudflare, which is the actual binary installed into node_modules/.bin/ by the @opennextjs/cloudflare package. This is consistent with:

  • The deploy delegation in open-next.ts (line 33), which already uses opennextjs-cloudflare
  • The packageJsonScriptsOverrides in the same file (lines 52–53), which also use opennextjs-cloudflare
  • The Qwik handler's existing pnpm workaround, which documents this as a known class of issue

The unscoped binary name resolves correctly across all package managers: npx opennextjs-cloudflare build, pnpm opennextjs-cloudflare build, yarn opennextjs-cloudflare build, and bunx opennextjs-cloudflare build.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: the change is a string substitution in command construction; the existing autoconfig test suite (53 tests) passes, and there are no unit tests that exercise the Next.js handler's configure() method directly (it requires a real Next.js project with @opennextjs/cloudflare installed)
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is a bug fix with no user-facing API change

Open with Devin

@MattieTK MattieTK requested a review from a team as a code owner February 7, 2026 17:46
@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: e3927fb

The changes in this PR will be included in the next version bump.

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

@claude
Copy link
Contributor

claude bot commented Feb 7, 2026

Claude finished @MattieTK's task —— View job


Changeset Review Complete

  • Read changeset guidelines
  • Read changeset file
  • Validate changeset
  • Post review findings

All changesets look good

The changeset .changeset/fix-opennext-pnpm-scoped-binary.md is well-formatted and follows all guidelines:

  • Version Type: ✅ Correctly classified as patch (bug fix)
  • Changelog Quality: ✅ Clear, detailed description explaining the root cause (pnpm workspace filter interpretation) and the solution (using unscoped binary name)
  • Markdown Headers: ✅ No h1/h2/h3 headers used
  • Package Coverage: ✅ Correctly targets wrangler only
  • Format: ✅ Follows the title + body structure with imperative description

The changeset provides excellent context about the pnpm-specific failure and clearly explains why the fix works across all package managers.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12476

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12476

miniflare

npm i https://pkg.pr.new/miniflare@12476

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12476

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12476

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12476

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12476

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12476

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12476

wrangler

npm i https://pkg.pr.new/wrangler@12476

commit: e3927fb

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 7, 2026
@MattieTK
Copy link
Member Author

MattieTK commented Feb 7, 2026

Wait for this to be merged and for tests to pass when rebased to that before merging.

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matt 🙂

pnpm interprets scoped package names (@scope/name) as workspace filters,
causing `wrangler deploy --x-autoconfig` to fail for pnpm-based Next.js
projects. Use the unscoped binary name `opennextjs-cloudflare` instead,
consistent with the existing deploy delegation and script overrides.
@petebacondarwin petebacondarwin force-pushed the fix/opennext-pnpm-scoped-binary branch from b1b489a to 7d18052 Compare February 9, 2026 21:15
@petebacondarwin petebacondarwin merged commit 62a8d48 into main Feb 10, 2026
35 checks passed
@petebacondarwin petebacondarwin deleted the fix/opennext-pnpm-scoped-binary branch February 10, 2026 10:29
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants