React Router V7 Prisma Support (Exports is not defined)
can someone assist me please?
in my schema i have the following
and i have a db.server.ts file for my react-router v7 app the code as folllowed
but im receiving the error below and cant seem to fix it any help would be greatly appreciated

1 Reply
You opted for speed from this bot. Let's conjure up an answer right now!
The error exports is not defined typically occurs when the generated Prisma Client is used in an ESM (ECMAScript Module) environment, but the generated code is still CommonJS, or vice versa. This is a common issue when using Vite, React Router v7, and custom Prisma Client output paths.
Key points and solutions from the knowledge sources:
1. Output Location:
When using Vite (and similar ESM-based tools), generating the Prisma Client into a custom directory (like ../generated/prisma) can cause module resolution issues. Multiple users have resolved this by generating the client into a directory inside node_modules, such as ../node_modules/@custom-prisma/client, and then importing from that package name instead of a relative path. This works because Vite and other bundlers treat node_modules differently and expect packages there to be properly formatted for ESM or CJS as needed.
Example: Then import: See discussion and solution 2. Module Format:
The module = "esm" option in your generator config is not standard for Prisma and may not be recognized. Instead, Prisma v7+ uses provider = "prisma-client" for ESM support, but this is still evolving and may have compatibility issues with some bundlers. If you use provider = "prisma-client-js", ensure your environment matches the expected module system. 3. Vite and SSR:
Vite SSR environments are especially sensitive to module format mismatches. Generating the client into node_modules and importing as a package is the most reliable workaround. Summary of what to do: - Change your generator output to a directory inside node_modules (e.g., ../node_modules/@custom-prisma/client). - Update your import to use the new pack age name. - Remove non-standard generator options like module and engine. Example generator: Example import: This should resolve the exports is not defined error with Vite and React Router v7 setups source. ✅ Great, thanks for letting us know that this solved your question!
When using Vite (and similar ESM-based tools), generating the Prisma Client into a custom directory (like ../generated/prisma) can cause module resolution issues. Multiple users have resolved this by generating the client into a directory inside node_modules, such as ../node_modules/@custom-prisma/client, and then importing from that package name instead of a relative path. This works because Vite and other bundlers treat node_modules differently and expect packages there to be properly formatted for ESM or CJS as needed.
Example: Then import: See discussion and solution 2. Module Format:
The module = "esm" option in your generator config is not standard for Prisma and may not be recognized. Instead, Prisma v7+ uses provider = "prisma-client" for ESM support, but this is still evolving and may have compatibility issues with some bundlers. If you use provider = "prisma-client-js", ensure your environment matches the expected module system. 3. Vite and SSR:
Vite SSR environments are especially sensitive to module format mismatches. Generating the client into node_modules and importing as a package is the most reliable workaround. Summary of what to do: - Change your generator output to a directory inside node_modules (e.g., ../node_modules/@custom-prisma/client). - Update your import to use the new pack age name. - Remove non-standard generator options like module and engine. Example generator: Example import: This should resolve the exports is not defined error with Vite and React Router v7 setups source. ✅ Great, thanks for letting us know that this solved your question!