nextjs - ✅(Solved) Fix Next.js (Turbopack) fails to find/load native node addon compiled as a separate package in a (pnpm) workspace [1 pull requests, 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#85449Fetched 2026-04-08 02:15:39
View on GitHub
Comments
5
Participants
4
Timeline
12
Reactions
3
Author
Timeline (top)
commented ×5subscribed ×4cross-referenced ×1issue_type_added ×1

Error Message

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: (void 0) is not a function at c (.next/server/chunks/ssr/[root-of-the-server]__9aa9e4ec._.js:1:392) at stringify (<anonymous>) { digest: '3868626329' } Export encountered an error on /page: /, exiting the build.

Fix Action

Fixed

PR fix notes

PR #2382: Update to Next.js 16

Description (problem / solution / changelog)

The default bundler switched from Webpack to Turbopack, but we cannot use it yet as I cannot get native node addons to work (see https://github.com/vercel/next.js/issues/85449). Therefore, we will stick to Webpack for now.

Closes #2367 Closes #2370 Closes #2374

Changed files

  • app/.gitignore (modified, +1/-0)
  • app/eslint.config.mjs (modified, +21/-12)
  • app/next-env.d.ts (removed, +0/-6)
  • app/package.json (modified, +7/-7)
  • app/src/app/api/author/scat-cs/route.ts (modified, +1/-1)
  • app/src/app/api/middleware/cors.ts (modified, +3/-3)
  • app/src/app/api/route-builder.ts (modified, +1/-1)
  • app/src/app/api/scat-cs/inspect/legacy/route.ts (modified, +1/-1)
  • app/src/app/api/scat-css/LTPDocument/route.ts (modified, +1/-1)
  • app/src/app/api/scat-css/LTPMixture/route.ts (modified, +1/-1)
  • app/src/app/api/scat-css/[id]/legacy/route.ts (modified, +1/-1)
  • app/src/app/api/scat-css/schema/upload-document/route.ts (modified, +1/-1)
  • app/src/app/api/states/in-reaction/route.ts (modified, +1/-1)
  • app/src/app/scat-cs/client-page.tsx (modified, +1/-1)
  • app/src/app/scat-cs/inspect/process-plot.tsx (modified, +3/-3)
  • app/src/app/scat-cs/inspect/process-table.tsx (modified, +8/-10)
  • app/src/auth/arango-adapter.ts (modified, +1/-1)
  • app/src/docs/generator.ts (modified, +2/-2)
  • app/src/docs/openapi.ts (modified, +2/-2)
  • app/src/shared/header/nav-bar.tsx (modified, +3/-2)
  • app/src/shared/line-plot.tsx (modified, +5/-5)
  • app/src/shared/swr-state-select.tsx (modified, +2/-2)
  • pnpm-lock.yaml (modified, +118/-269)

Code Example

pnpm i

---

pnpm -C packages/rust-lib build

---

pnpm -C packages/web-app build

---

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
  TypeError: (void 0) is not a function
      at c (.next/server/chunks/ssr/[root-of-the-server]__9aa9e4ec._.js:1:392)
      at stringify (<anonymous>) {
    digest: '3868626329'
  }
  Export encountered an error on /page: /, exiting the build.

---

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
  TypeError: (void 0) is not a function
      at c (.next/server/chunks/ssr/[root-of-the-server]__9aa9e4ec._.js:1:392)
      at stringify (<anonymous>) {
    digest: '3868626329'
  }
  Export encountered an error on /page: /, exiting the build.

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #1-NixOS SMP PREEMPT_DYNAMIC Thu Sep 11 15:21:47 UTC 2025
  Available memory (MB): 64179
  Available CPU cores: 48
Binaries:
  Node: 22.20.0
  npm: N/A
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.0
  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/daanboer/next-load-native-module

To Reproduce

  • Install dependencies.
pnpm i
  • Build the rust-lib package (needs a working rust installation).
pnpm -C packages/rust-lib build
  • Try to build the web-app package.
pnpm -C packages/web-app build

The web-app build process will throw the following error:

  Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
  TypeError: (void 0) is not a function
      at c (.next/server/chunks/ssr/[root-of-the-server]__9aa9e4ec._.js:1:392)
      at stringify (<anonymous>) {
    digest: '3868626329'
  }
  Export encountered an error on /page: /, exiting the build.

Current vs. Expected behavior

This is a followup of #71630, which highlights a similar issue when using webpack. As the default bundler switched to turbopack, I ran into this issue instead.

I expect the greet function declared in the rust-lib package to be called successfully. Instead I get the following error at build time:

  Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
  TypeError: (void 0) is not a function
      at c (.next/server/chunks/ssr/[root-of-the-server]__9aa9e4ec._.js:1:392)
      at stringify (<anonymous>) {
    digest: '3868626329'
  }
  Export encountered an error on /page: /, exiting the build.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1-NixOS SMP PREEMPT_DYNAMIC Thu Sep 11 15:21:47 UTC 2025
  Available memory (MB): 64179
  Available CPU cores: 48
Binaries:
  Node: 22.20.0
  npm: N/A
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.0
  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 dev (local), next build (local), next start (local)

Additional context

The native node addon is built using napi. I have added rust-lib to serverExternalPackages, but that does not solve the issue.

extent analysis

TL;DR

  • The issue is likely due to incorrect handling of the native node addon built with napi, and a workaround may involve adjusting the Next.js configuration or the way the addon is loaded.

Guidance

  • Verify that the rust-lib package is correctly built and exported, and that the greet function is properly declared and exported.
  • Check the Next.js configuration to ensure that the serverExternalPackages option is correctly set up to include the rust-lib package.
  • Investigate the possibility of a version mismatch between the native node addon and the Next.js version, and consider updating or downgrading as needed.
  • Try to load the rust-lib package dynamically using a require statement or an import statement with a conditional check, to see if it resolves the issue.

Example

// Example of dynamic loading
if (typeof window === 'undefined') {
  const rustLib = require('rust-lib');
  // Use the rustLib here
}

Notes

  • The issue seems to be related to the new turbopack bundler, which may handle native node addons differently than the previous webpack bundler.
  • The provided error message does not give a clear indication of the root cause, so further investigation is needed to determine the exact solution.

Recommendation

  • Apply workaround: Try adjusting the Next.js configuration or the way the native node addon is loaded, as the issue seems to be related to the interaction between Next.js and the addon.

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