#Can't compile with nextjs

1 messages · Page 1 of 1 (latest)

buoyant oracle
#

Build error occurred
Error: Turbopack build failed with 1 errors:
./lib/generated/prisma/client.ts
Code generation for chunk item errored
An error occurred while generating the chunk item [project]/lib/generated/prisma/client.ts [app-client] (ecmascript) <locals>

Caused by:

  • the chunking context (unknown) does not support external modules (request: node:module)

Debug info:

  • An error occurred while generating the chunk item [project]/lib/generated/prisma/client.ts [app-client] (ecmascript) <locals>
  • Execution of <MergedEcmascriptModuleChunkItem as EcmascriptChunkItem>::content_with_async_module_info failed
  • Execution of *EcmascriptChunkItemContent::new failed
  • Execution of EcmascriptModuleContent::new_merged failed
  • the chunking context (unknown) does not support external modules (request: node:module)

Import traces:
Server Component:
./lib/generated/prisma/client.ts
./app/[locale]/(home)/page.tsx

App Route:
./lib/generated/prisma/client.ts
./schemas/property.schema.ts
./app/api/properties/[propertyId]/route.ts

Client Component Browser:
./lib/generated/prisma/client.ts [Client Component Browser]
./components/main/explore/filters-sidebar.tsx [Client Component Browser]
./app/[locale]/(home)/explore/page.tsx [Client Component Browser]
./app/[locale]/(home)/explore/page.tsx [Server Component]

Client Component SSR:
./lib/generated/prisma/client.ts [Client Component SSR]
./components/main/explore/filters-sidebar.tsx [Client Component SSR]
./app/[locale]/(home)/explore/page.tsx [Client Component SSR]
./app/[locale]/(home)/explore/page.tsx [Server Component]

daring iceBOT
#

You opted for speed from this bot. Let's conjure up an answer right now!

daring iceBOT
# daring ice You opted for speed from this bot. Let's conjure up an answer right now!

The error you're encountering with Turbopack and Next.js—specifically, "the chunking context (unknown) does not support external modules (request: node:module)" when importing your generated Prisma client—has been reported by other users in similar setups, especially in monorepos or when using custom output paths for the Prisma client.

Key points from the knowledge sources:

  • This error often occurs when server-only code (like the Prisma client) is imported into client components or shared code that ends up in the client bundle. Prisma's generated client is not compatible with the browser and should only be used in server components or API routes, not in client components or code that is imported by them. Accidentally importing the Prisma client into a client component will cause bundlers like Turbopack or Webpack to fail, as they cannot handle Node.js-specific modules in the browser context see discussion.
  • The import trace you provided shows that ./lib/generated/prisma/client.ts is being imported by both server and client components. This is likely the root cause. You must ensure that any code importing the Prisma client is only used in server-side code.
  • There is no direct fix in Prisma itself for this; the solution is architectural: separate your server-only code (Prisma client) from code that is shared with or imported by client components. If you need to share types, consider generating and exporting only types for the client, not the full Prisma client instance.
  • This issue is not unique to your setup and has been discussed in the context of Next.js, Turbopack, and monorepos. See similar errors and explanations in this issue.

What you should do:

  • Audit your imports and ensure that lib/generated/prisma/client.ts is only imported in server components, API routes, or other server-only files.
  • If you need to share types, create a separate
daring iceBOT
# daring ice You opted for speed from this bot. Let's conjure up an answer right now!

file that only exports types (not the Prisma client instance) for use in client components.

If you follow these guidelines and still encounter issues, it may be related to ongoing compatibility problems between Turbopack and certain server-only packages, as discussed in the linked issues. In that case, you may need to follow updates from the Next.js and Prisma teams for further fixes.

daring iceBOT
buoyant oracle
#

Just updated to v7

spark sonnet
#

I assume this is resolved now, right?