nextjs - 💡(How to fix) Fix [Turbopack] Build fails with "module factory is not available" when using `export * as X from "."` [5 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#88534Fetched 2026-04-08 02:04:33
View on GitHub
Comments
5
Participants
4
Timeline
10
Reactions
0
Timeline (top)
commented ×5labeled ×2closed ×1issue_type_added ×1

Error Message

Error: Module 8147 was instantiated because it was required from module 56356, but the module factory is not available.

Root Cause

Current: Build fails with:

Error: Module 8147 was instantiated because it was required from module 56356, but the module factory is not available.

Fix Action

Fix / Workaround

Workaround: Replace with TypeScript namespaces:

export namespace User {
  export function fromSession() { ... }
}

Code Example

Error: Module 8147 was instantiated because it was required from module 56356, but the module factory is not available.

---

// lib/user/index.ts
export * as User from "."
export function fromSession() { ... }

// Usage:
import { User } from "@/lib/user"
await User.fromSession()

---

export namespace User {
  export function fromSession() { ... }
}

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin 25.2.0
Binaries:
  Node: 22.12.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 16.1.1
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.9.3
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/roguesherlock/turbopack-export-star-repro

To Reproduce

  1. Clone the reproduction repo: git clone https://github.com/roguesherlock/turbopack-export-star-repro
  2. Install dependencies: bun install
  3. Build with Turbopack: bun run build
  4. Observe the build failure

Current vs. Expected behavior

Current: Build fails with:

Error: Module 8147 was instantiated because it was required from module 56356, but the module factory is not available.

Expected: Build should complete successfully. The export * as X from "." pattern is valid TypeScript and works with Webpack (non-Turbopack builds).

Context: This pattern is commonly used to create namespace-like exports:

// lib/user/index.ts
export * as User from "."
export function fromSession() { ... }

// Usage:
import { User } from "@/lib/user"
await User.fromSession()

Workaround: Replace with TypeScript namespaces:

export namespace User {
  export function fromSession() { ... }
}

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin 25.2.0
Binaries:
  Node: 22.12.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 16.1.1
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.9.3

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

Turbopack

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

next build (local)

Additional context

  • Dev mode (next dev --turbopack) works fine
  • Only fails during production build
  • Works correctly with Webpack (without Turbopack)

extent analysis

TL;DR

Replace the export * as X from "." pattern with TypeScript namespaces to resolve the Turbopack build failure.

Guidance

  • Identify all occurrences of the export * as X from "." pattern in the codebase and consider replacing them with TypeScript namespaces.
  • Verify that the replacement does not introduce any new issues or errors by testing the build and runtime behavior.
  • If replacing the pattern is not feasible, consider using Webpack instead of Turbopack for production builds, as the issue does not occur with Webpack.
  • Investigate whether there are any open issues or pull requests in the Turbopack repository that address this specific problem.

Example

// Before
export * as User from "."

// After
export namespace User {
  export function fromSession() { ... }
}

Notes

This solution assumes that replacing the export * as X from "." pattern with TypeScript namespaces does not introduce any significant changes to the code's behavior or functionality. Additionally, this workaround may not be suitable for all use cases, and further investigation may be necessary to determine the root cause of the issue.

Recommendation

Apply workaround: Replace the export * as X from "." pattern with TypeScript namespaces, as this is a known solution that resolves the build failure with Turbopack.

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 [Turbopack] Build fails with "module factory is not available" when using `export * as X from "."` [5 comments, 4 participants]