PrismaP
Prisma•3mo ago•
6 replies
jsuis goastesque

Issue with Prisma export in Turborepo + Express setup

Hey everyone đź‘‹

I'm running into an issue with my Turborepo setup that includes Prisma and Express.js.
When I try to start my dev server with npx turbo dev, I get the following error:

The requested module does not provide an export named 'prisma'


Here’s some context:

I have a @repo/db package where my Prisma client is initialized and exported like this:
import { withAccelerate } from "@prisma/extension-accelerate";
import { PrismaClient } from "./generated/prisma/client";

const globalForPrisma = global as unknown as { prisma: PrismaClient };

export const prisma =
    globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate());

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

export * from "./generated/prisma/client";


In my Express app (in another package), I import it like this:
import { prisma } from '@repo/db'


The code compiles fine, but when running the dev command through Turborepo, it crashes with that export error.

It seems like Turborepo (or maybe Node’s ESM handling) isn’t recognizing the named export from my Prisma module.

Has anyone else run into this issue?
Any idea if it’s related to module resolution between packages or how ESM/CJS is configured in Turborepo?

Thanks in advance 🙏

my repo: https://github.com/SpinBoxx/prisma-monorepo
GitHub
Contribute to SpinBoxx/prisma-monorepo development by creating an account on GitHub.
GitHub - SpinBoxx/prisma-monorepo
Was this page helpful?