T
TanStack6mo ago
absent-sapphire

Prisma import fails in monorepo deployed on Vercel

Looking into deploying tanstack start from a Turborepo on Vercel. I've got some issues import issues from the db package (prisma wrapper). Basically, the generator client looks like this:
generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder", "typedSql"]
output = "../../../../node_modules/@prisma-app/client"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder", "typedSql"]
output = "../../../../node_modules/@prisma-app/client"
}
My app.config.ts looks like this:
import { defineConfig } from '@tanstack/react-start/config';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
preset: 'vercel',
},
tsr: {
appDirectory: 'src',
},
vite: {
build: {
rollupOptions: {
external: ['@prisma-app/client'],
}
},
define: {
global: {},
},
plugins: [
tsConfigPaths({
projects: [
'./tsconfig.json',
'../../packages/ui/tsconfig.json',
'../../packages/auth/tsconfig.json',
],
}),
],
},
});
import { defineConfig } from '@tanstack/react-start/config';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
preset: 'vercel',
},
tsr: {
appDirectory: 'src',
},
vite: {
build: {
rollupOptions: {
external: ['@prisma-app/client'],
}
},
define: {
global: {},
},
plugins: [
tsConfigPaths({
projects: [
'./tsconfig.json',
'../../packages/ui/tsconfig.json',
'../../packages/auth/tsconfig.json',
],
}),
],
},
});
However, in the logs of the deployed version I'm getting the following error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@prisma-app/client' imported from I specify this works as expected on local dev server. Any clue why this is happening & what should I do. I can provide more config info if needed.
8 Replies
absent-sapphire
absent-sapphireOP6mo ago
Mhm... can this be related to prisma on not on tanstack start? @Manuel Schiller any clues what might wrong here or how to fix?
ratty-blush
ratty-blush6mo ago
no however i think the upcoming prisma release will resolve this since it moves generation out of node_modules folder?
variable-lime
variable-lime6mo ago
@mariusflorescu were you using vite before? Could the be the tsconfig paths aren't setup correctly OR you need to setup turborepo deps properly so it builds the prisma types, before it builds the app i.e. yarn turbo build should proxy to build which relies on build:prisma-types this is done in the turbo.json also is your nodemodules really 4 levels deep? output = "../../../../node_modules/@prisma-app/client"
absent-sapphire
absent-sapphireOP6mo ago
No, we weren’t using vite before, we are migrating from nextjs. Yes, 4 levels deep since the generator is in packages/db/prisma/schema.prisma. The build of the app depends on the build of the db package
variable-lime
variable-lime6mo ago
that error you get when doing vite build right? oh wait in the DEPLOYED version Can you share your dockerfile I have a idea... or w/e you use to package
absent-sapphire
absent-sapphireOP6mo ago
No, it’s deployed on vercel
variable-lime
variable-lime6mo ago
hmmm well my thinking is that is gone because of turborepo prune or a missed step during build how does prisma client get generated during build process?
absent-sapphire
absent-sapphireOP6mo ago
@Zac it’s a pnpm build script that runs prisma db generate command in order to get the prisma client generated For everybody that might see this: I was really stupid, I didn’t install the db package in my app 🙂 which was working fine LOCALLY since other packages were installing the db package and it got into the node modules.

Did you find this page helpful?