nextjs - ✅(Solved) Fix Standalone build missing files for packages using module-sync exports condition (Node.js >= 22.10) [1 pull requests, 1 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#90567Fetched 2026-04-08 00:19:49
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

Error Message

⨯ Error: Failed to load external module axios-fc13683ac9a02a51: Error: Cannot find module '/path/to/.next/standalone/node_modules/async-function/require.mjs' at Context.externalImport [as y] (.next/server/chunks/ssr/[turbopack]_runtime.js:518:15)

Root Cause

The async-function package has the following exports in its package.json:

"exports": {
  ".": [
    {
      "module-sync": "./require.mjs",
      "import": "./index.mjs",
      "default": "./index.js"
    },
    "./index.js"
  ]
}

The module-sync condition became a default condition in Node.js 22.10.0 (release notes). At runtime, Node.js >= 22.10 resolves module-sync (higher priority) → require.mjs. But @vercel/nft only traces the default condition → index.js, so require.mjs is never copied to the standalone output.

Fix Action

Workaround

// next.config.mjs
outputFileTracingIncludes: {
  '/**': [
    './node_modules/async-function/require.mjs',
    './node_modules/async-generator-function/require.mjs',
    './node_modules/generator-function/require.mjs',
  ],
},

This is fragile — any new dependency using module-sync exports will require manually adding more entries.

PR fix notes

PR #534: feat: add support for module-sync export condition in Node.js 22+

Description (problem / solution / changelog)

This PR implements support for the module-sync export condition in package.json exports, which is available in Node.js 22 and later versions. The feature enables packages to provide synchronous ES module loading behavior for enhanced performance in supported Node.js versions. Unit tests added with process.versions.node mocked

  • Fixes #531

Changed files

Code Example

Error: Failed to load external module axios-fc13683ac9a02a51: Error: Cannot find module
'/path/to/.next/standalone/node_modules/async-function/require.mjs'
    at Context.externalImport [as y] (.next/server/chunks/ssr/[turbopack]_runtime.js:518:15)

---

"exports": {
  ".": [
    {
      "module-sync": "./require.mjs",
      "import": "./index.mjs",
      "default": "./index.js"
    },
    "./index.js"
  ]
}

---

// next.config.mjs
outputFileTracingIncludes: {
  '/**': [
    './node_modules/async-function/require.mjs',
    './node_modules/async-generator-function/require.mjs',
    './node_modules/generator-function/require.mjs',
  ],
},
RAW_BUFFERClick to expand / collapse

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release (16.2.0-canary.62 still bundles @vercel/[email protected])

Provide environment information

  • Next.js: 16.1.6 (also reproduced on canary)
  • Node.js: 24.12.0
  • OS: macOS (Darwin 24.5.0)
  • Build mode: output: 'standalone'

Which area(s) of Next.js are affected?

Output (Standalone Build), File Tracing

To Reproduce

  1. Create a Next.js 16 app with output: 'standalone' and Pages Router
  2. Add a dependency that transitively pulls in a package using the module-sync exports condition. For example, axios[email protected][email protected][email protected][email protected]
  3. Create a page with getServerSideProps that uses axios
  4. Run next build
  5. Start with node .next/standalone/server.js on Node.js >= 22.10
  6. Visit the SSR page

Note: Whether this reproduces depends on your lockfile resolving get-intrinsic to 1.3.1 (which added async-function as a dependency). You can force it with npm overrides or yarn resolutions: "get-intrinsic": "1.3.1".

Expected behavior

The standalone server renders the page successfully.

Actual behavior

⨯ Error: Failed to load external module axios-fc13683ac9a02a51: Error: Cannot find module
'/path/to/.next/standalone/node_modules/async-function/require.mjs'
    at Context.externalImport [as y] (.next/server/chunks/ssr/[turbopack]_runtime.js:518:15)

The standalone output contains node_modules/async-function/index.js and package.json, but is missing require.mjs.

Root cause

The async-function package has the following exports in its package.json:

"exports": {
  ".": [
    {
      "module-sync": "./require.mjs",
      "import": "./index.mjs",
      "default": "./index.js"
    },
    "./index.js"
  ]
}

The module-sync condition became a default condition in Node.js 22.10.0 (release notes). At runtime, Node.js >= 22.10 resolves module-sync (higher priority) → require.mjs. But @vercel/nft only traces the default condition → index.js, so require.mjs is never copied to the standalone output.

Fix already available

This was already reported and fixed in @vercel/nft:

Next.js 16.1.6 and canary 16.2.0-canary.62 both still bundle @vercel/[email protected]. Bumping to >= 0.30.0 would fix this.

Workaround

// next.config.mjs
outputFileTracingIncludes: {
  '/**': [
    './node_modules/async-function/require.mjs',
    './node_modules/async-generator-function/require.mjs',
    './node_modules/generator-function/require.mjs',
  ],
},

This is fragile — any new dependency using module-sync exports will require manually adding more entries.

Impact

Node.js 24 is the current LTS. Any Next.js project using standalone output on Node.js >= 22.10 is affected if its dependency tree includes packages with module-sync exports.

extent analysis

Problem Summary

Standalone builds on Node ≥ 22.10 fail when a dependency uses the new module‑sync export condition because the tracing tool (@vercel/nft) does not copy the require.mjs file.

Root Cause Analysis

@vercel/[email protected] only follows the default export condition, so it misses require.mjs that Node now prefers (module‑sync). The issue is fixed in @vercel/[email protected].

Fix Plan

1. Upgrade `@

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…

FAQ

Expected behavior

The standalone server renders the page successfully.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING