nextjs - 💡(How to fix) Fix Experimental Build Mode `generate` step fails with no such file or directory [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86753Fetched 2026-04-08 02:09:27
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Author
Participants
Timeline (top)
labeled ×3subscribed ×3commented ×2issue_type_added ×1

Error Message

Error: ENOENT: no such file or directory, rename '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js' -> '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js' at ignore-listed frames { errno: -2, code: 'ENOENT', syscall: 'rename', path: '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js', dest: '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js' }

Code Example

next build --debug --webpack --experimental-build-mode compile

---

next build --debug --webpack --experimental-build-mode generate

---

Error: ENOENT: no such file or directory, rename '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js' -> '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js'
    at ignore-listed frames {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js',
  dest: '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js'
}

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:34 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/m-sanders/nextjs-experimental-build-mode-proxy-bug

To Reproduce

Create a Next.js 16.0.6 project with a proxy.ts file in the root directory

Run the compile step:

next build --debug --webpack --experimental-build-mode compile

Run the generate step:

next build --debug --webpack --experimental-build-mode generate

Current vs. Expected behavior

The generate step fails with the following error:

Error: ENOENT: no such file or directory, rename '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js' -> '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js'
    at ignore-listed frames {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/Users/me/code/next-16-experimental-build-mode/.next/server/proxy.js',
  dest: '/Users/me/code/next-16-experimental-build-mode/.next/server/middleware.js'
}

Expected Behavior

The generate step should complete successfully without errors.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:34 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Middleware, Turbopack, Webpack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

extent analysis

TL;DR

  • The issue can be mitigated by ensuring the proxy.js file exists in the expected location before running the generate step.

Guidance

  • Verify that the proxy.ts file is correctly compiled to proxy.js in the .next/server directory during the compile step.
  • Check the file system permissions to ensure that the rename operation is allowed.
  • Consider adding a check to ensure that the proxy.js file is present before attempting to rename it.
  • Review the Next.js configuration and build process to ensure that the proxy.ts file is being correctly handled.

Example

  • No explicit code example is provided, but reviewing the nextjs-experimental-build-mode-proxy-bug repository may offer insight into the issue.

Notes

  • The issue appears to be related to the experimental build mode and proxy configuration in Next.js.
  • The provided environment information and package versions may be relevant to the issue.

Recommendation

  • Apply workaround: Modify the build process to ensure the proxy.js file is present and correctly handled before running the generate step, as the root cause of the issue is not explicitly stated and may require further investigation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Experimental Build Mode `generate` step fails with no such file or directory [2 comments, 2 participants]