PrismaP
Prisma2mo ago
4 replies
DeathSoulYT

React Router V7 Prisma Support (Exports is not defined)

can someone assist me please?
in my schema i have the following

generator client {
  output       = "../generated/prisma"
  provider     = "prisma-client-js"
  engineType   = "binary"
  engine       = "binary"
  module       = "esm"
  runtime      = "nodejs"
}

and i have a db.server.ts file for my react-router v7 app the code as folllowed

// utils/db.server.ts
import { PrismaClient } from "generated/prisma"; // match your generator output

declare global {
  var prisma: PrismaClient | undefined;
}

// Prevent multiple instances in dev (hot reload)
export const prisma =
  global.prisma ||
  new PrismaClient({
    log: ["query","error","info","warn"], // optional, useful for debugging
  });

if (process.env.NODE_ENV !== "production") global.prisma = prisma;


but im receiving the error below and cant seem to fix it any help would be greatly appreciated

exports is not defined
    at eval (C:/Users/dgrav/Documents/bcs-main/generated/prisma/index.js:8:23)
    at ESModulesEvaluator.runInlinedModule (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:913:161)
    at SSRCompatModuleRunner.directRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:1146:80)
    at SSRCompatModuleRunner.directRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/chunks/config.js:15768:22)
    at SSRCompatModuleRunner.cachedRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:1053:73)
    at eval (C:/Users/dgrav/Documents/bcs-main/app/utils/db.server.ts:4:31)
    at ESModulesEvaluator.runInlinedModule (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:913:3)
    at SSRCompatModuleRunner.directRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:1146:59)
    at SSRCompatModuleRunner.directRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/chunks/config.js:15768:22)
    at SSRCompatModuleRunner.cachedRequest (file:///C:/Users/dgrav/Documents/bcs-main/node_modules/vite/dist/node/module-runner.js:1053:73)
image.png
Was this page helpful?