Prisma turborepo deployment not initialized error

Having issues with the Prisma initializations only on deployments using Turborepo. Anyone encountered the same issues? Works locally, the client is generated as included in part of the build process, but on deployments, I get an error as it's not initialized in the web app.
9 Replies
Sebastian
Sebastian•10mo ago
I have a package in /packages named database, which exports * from '@prisma/client' I have setup the package.json right, I can work with the database package locally and while developing, I checked that the client is generated after removing node_modules, bun.lockb and simulate the build process.
iDarkLightning
iDarkLightning•10mo ago
send the errors and maybe someone can help
Sebastian
Sebastian•10mo ago
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
This is the error displayed in vercel logs. This is the initialization in the apps/web The error comes after trying to import prisma in a /pages folder in order to use it in getServerSideProps for doing a check. However, the blocker is the displayed error.
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
So @prisma/client is only installed in @kleerk/database, and it has an index.ts which does
export * from "@prisma/client"
export * from "@prisma/client"
The basic example on turborepo prisma docs. Then the initialization is done in the other packages which want to use PrismaClient. At build time, it depends on a "db:generate" which generates the client and types for prisma
Vagner Maltauro
Vagner Maltauro•10mo ago
import { PrismaClient } from "@kleerk/database";
import { PrismaClient } from "@kleerk/database";
🤔
Sebastian
Sebastian•10mo ago
They displayed this as an example for how to setup turborepo with prisma https://turbo.build/repo/docs/handbook/tools/prisma
Vagner Maltauro
Vagner Maltauro•10mo ago
.
No description
Sebastian
Sebastian•10mo ago
yeah, that's how I defined the database package in my monorepo
Sebastian
Sebastian•10mo ago
Wow, for anybody else who can't read like me, the solution is in the error message. Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs apparently it's a known issue and it's even a workaround plugin from prisma for monorepos.
Prisma
Using Prisma Client in a Next.js project in a monorepo setup
Using Prisma Client in a Next.js project in a monorepo setup
Want results from more Discord servers?
Add your server