nextjs - ✅(Solved) Fix Turbopack production error: Module X was instantiated because it was required from module X, but the module factory is not available. [2 pull requests, 4 comments, 4 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#86132Fetched 2026-04-08 02:12:24
View on GitHub
Comments
4
Participants
4
Timeline
21
Reactions
6
Timeline (top)
subscribed ×7commented ×4labeled ×3cross-referenced ×2

Error Message

Error: Failed to collect configuration for / at ignore-listed frames { [cause]: Error: Module 28932 was instantiated because it was required from module 33290, but the module factory is not available. at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:707:15) at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12) at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]runtime.js:228:20) at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__8023723c..js:1:755) at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9) at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12) at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]runtime.js:228:20) at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__aa0032af..js:1:268) at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9) at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12) }

Root Cause

Current: crash/500 with error::

Error: Failed to collect configuration for /
    at ignore-listed frames {
  [cause]: Error: Module 28932 was instantiated because it was required from module 33290, but the module factory is not available.
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:707:15)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__8023723c._.js:1:755)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__aa0032af._.js:1:268)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
}

Fix Action

Fixed

PR fix notes

PR #86131: Turbopack: scope hoisting bug with reexport-self-star

Description (problem / solution / changelog)

Closes PACK-5850 Closes https://github.com/vercel/next.js/issues/86132 Closes #86714

The problem was that you get this with scope hoisting:

"index.js": () => {

// foo.js

// exports object read here
const self_import = turbopack_import("foo.js")

// exports object created here
__turbopack_esm__([...], "foo.js")

// index.js

....
}

without scope hoisting, that exports object is already initialized before the module factory runs

"foo.js": () => { // exports initialized here

const self_import = turbopack_import("foo.js")


__turbopack_esm__([....]);
}
....

so let's fix it by making it hoist the __turbopack_esm__ statement (just as we did before always) in the case of self-imports


This bug is actually very similar to https://github.com/vercel/next.js/pull/82827. It also executes data.js twice.

The problem is that if a module imports itself,

"[project]/input/data.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";

var __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/input/data.js [test] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/input/data.js [test] (ecmascript)");
__turbopack_context__.s([
    "Data",
    0,
    __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__,
    "bar",
    ()=>__TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$locals$3e$__["bar"],
    "foo",
    ()=>__TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$locals$3e$__["foo"]
]);
}),

and with scope hoisting, the import("id") happens before the esm_export(..., "id"):

module.exports = [
"[project]/index.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";

// MERGED MODULE: [project]/index.js [test] (ecmascript)
;
// MERGED MODULE: [project]/data.js [test] (ecmascript) <locals>
;
function foo() {
    return 'foo';
}
function bar() {
    return 'bar';
}
;
__turbopack_context__.s([
    "bar",
    ()=>bar,
    "foo",
    ()=>foo
], "[project]/data.js [test] (ecmascript) <locals>");
// MERGED MODULE: [project]/data.js [test] (ecmascript) <export * as Data>
;
// MERGED MODULE: [project]/data.js [test] (ecmascript)
;
var __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/data.js [test] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/data.js [test] (ecmascript)");
__turbopack_context__.s([
    "Data",
    0,
    __TURBOPACK__imported__module__$5b$project$2f$input$2f$data$2e$js__$5b$test$5d$__$28$ecmascript$29$__,
    "bar",
    ()=>bar,
    "foo",
    ()=>foo
], "[project]/data.js [test] (ecmascript)");

Changed files

  • turbopack/crates/turbopack-core/src/module_graph/binding_usage_info.rs (modified, +10/-3)
  • turbopack/crates/turbopack-core/src/module_graph/mod.rs (modified, +65/-3)
  • turbopack/crates/turbopack-core/src/module_graph/module_batches.rs (modified, +4/-3)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/exports/self-reexport-star/input/data.js (added, +9/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/exports/self-reexport-star/input/index.js (added, +6/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/exports/self-reexport-star/options.json (added, +3/-0)

Code Example

Error: Failed to collect configuration for /
    at ignore-listed frames {
  [cause]: Error: Module 28932 was instantiated because it was required from module 33290, but the module factory is not available.
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:707:15)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__8023723c._.js:1:755)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__aa0032af._.js:1:268)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
}

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 11
Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  next: 16.0.3 // Latest available version is detected (16.0.3).
  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/MisterJimson/turbo-bug-report

To Reproduce

  1. Run pnpm build && pnpm start
  2. Visit /

Current vs. Expected behavior

Current: crash/500 with error::

Error: Failed to collect configuration for /
    at ignore-listed frames {
  [cause]: Error: Module 28932 was instantiated because it was required from module 33290, but the module factory is not available.
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:707:15)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__8023723c._.js:1:755)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
      at Context.esmImport [as i] (.next/server/chunks/ssr/[turbopack]_runtime.js:228:20)
      at module evaluation (.next/server/chunks/ssr/[root-of-the-server]__aa0032af._.js:1:268)
      at instantiateModule (.next/server/chunks/ssr/[turbopack]_runtime.js:715:9)
      at getOrInstantiateModuleFromParent (.next/server/chunks/ssr/[turbopack]_runtime.js:738:12)
}

Expected: no crash, 200 http response, renders page

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 11
Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  next: 16.0.3 // Latest available version is detected (16.0.3).
  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)

Turbopack

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

next start (local)

Additional context

extent analysis

TL;DR

  • The most likely fix is to investigate and resolve the module instantiation issue related to Turbopack in the Next.js application.

Guidance

  • Review the commit that introduces the issue (https://github.com/MisterJimson/turbo-bug-report/commit/6d3d05088efaff2928ef0a9d90edebb5b72fb8b0) to understand the changes made and how they might be affecting Turbopack.
  • Check the Next.js documentation and Turbopack configuration to ensure that the module factory is correctly set up and available.
  • Verify that the issue is indeed related to the upgrade from Next 15 to Next 16 by trying to replicate the issue in a minimal example or by downgrading to Next 15 to confirm if the issue persists.
  • Investigate potential compatibility issues between Next 16, Turbopack, and other dependencies like React 19.2.0 and TypeScript 5.9.3.

Notes

  • The issue seems to be specific to the combination of Next 16 and Turbopack, as it works on Next 15.
  • Without more specific details about the code changes or the exact configuration of Turbopack, it's challenging to provide a precise fix.

Recommendation

  • Apply workaround: Temporarily downgrade to Next 15 until the compatibility issue with Turbopack in Next 16 can be fully understood and resolved, or wait for an update to Next or Turbopack that addresses this issue.

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 - ✅(Solved) Fix Turbopack production error: Module X was instantiated because it was required from module X, but the module factory is not available. [2 pull requests, 4 comments, 4 participants]