Prisma 7 cloudflare

Hello, I have updated to prisma 7 and ran into some issues while deploying to cloudflare. It fails during build.
13:37:01.063 ./src/lib/validation/profile.schema.ts
13:37:01.063 Module not found: Can't resolve '@/lib/generated/prisma/client'
13:37:01.065 ./src/lib/auth.ts
13:37:01.066 Module not found: Can't resolve './generated/prisma/client'
13:37:01.063 ./src/lib/validation/profile.schema.ts
13:37:01.063 Module not found: Can't resolve '@/lib/generated/prisma/client'
13:37:01.065 ./src/lib/auth.ts
13:37:01.066 Module not found: Can't resolve './generated/prisma/client'
db.ts:
import { PrismaClient } from './generated/prisma/client';

const prismaClientSingleton = () => {
return new PrismaClient({
accelerateUrl: process.env.DATABASE_URL!,
});
};

type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton;
};

const prisma = globalForPrisma.prisma || prismaClientSingleton();

export default prisma;
import { PrismaClient } from './generated/prisma/client';

const prismaClientSingleton = () => {
return new PrismaClient({
accelerateUrl: process.env.DATABASE_URL!,
});
};

type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton;
};

const prisma = globalForPrisma.prisma || prismaClientSingleton();

export default prisma;
schema.prisma
generator client {
provider = "prisma-client"
output = "../src/lib/generated/prisma"
}

datasource db {
provider = "postgresql"
}
generator client {
provider = "prisma-client"
output = "../src/lib/generated/prisma"
}

datasource db {
provider = "postgresql"
}
4 Replies
Prisma AI Help
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into #ask-ai for a quick spin!
Ankur Datta
Ankur Datta4d ago
Hi, in CF workers you need to create a fresh instance in every function (as the .env variables are not available out of the function scope). You could use our guide for reference and resolve the issue.
How to use Prisma ORM and Prisma Postgres with Cloudflare Workers |...
Learn how to use Prisma ORM in a Cloudflare Workers project
Molekulė
MolekulėOP4d ago
I used it previously without a worker, is it mandatory now? Also, do I have to run npx prisma generate when deploying to CF?
Molekulė
MolekulėOP4d ago
No description

Did you find this page helpful?