Next.js Discord

Discord Forum

Nextjs Error [ChunkLoadError] using bun Elysia and Prisma 7

Unanswered
Couch's Kingbird posted this in #help-forum
Open in Discord
Couch's KingbirdOP
What's the problem and how to solve it please..?

For the context, I use next js 16 + Elysia as API and Prisma 7.4

Error [ChunkLoadError]: Failed to load chunk server/chunks/[externals]_node:buffer00e2e67a..js from module [externals]/node:buffer [external] (node:buffer, cjs, async loader)
at <anonymous> (C:\Users....next\dev\server\chunks[root-of-the-server]7dd9dca6._.js:18:40)
at map (null)
at <anonymous> (C:\Users....next\dev\server\chunks[root-of-the-server]
7dd9dca6._.js:18:3)
at decodeBase64AsWasm (file:\C:\Users...\src\generated\prisma\internal\class.ts:42:22)
at <anonymous> (file:\C:\Users...\src\generated\prisma\internal\class.ts:52:18)
at processTicksAndRejections (null)
40 |
41 | async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
42 | const { Buffer } = await import('node:buffer')
| ^
43 | const wasmArray = Buffer.from(wasmBase64, 'base64')
44 | return new WebAssembly.Module(wasmArray)
45 | } {
clientVersion: '7.4.0',
[cause]: ResolveMessage {}

And complier options
"target": "ES2023",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "react-jsx",

Schema located in .src/prisma :

generator client {
  provider = "prisma-client"
  output   = "../generated/prisma"
  runtime = "bun"
}

datasource db {
  provider = "postgresql"
}

This error is caused by how the generated Prisma 7 client loads WebAssembly in your environment: it uses a dynamic ESM import of node:buffer, which Next.js 16’s dev/Turbopack server is trying (and failing) to bundle as a separate chunk.

1 Reply

Couch's KingbirdOP
Well, I just found that it work with webpack for some reasons but not turbopack..