[tRPC] server app cannot find prisma folder as it's in trpc package
My turborepo is split up in trpc package for 1. server to use prisma queries and for 2. client to use type of trpc routers. As prisma calls are made in routes, prisma folder is generated for trpc package and Prisma Schema is there too, not server app. Prisma looks for prisma folder under app/server and fails.
the error occurs when prisma makes a db call
3 Replies
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
This is a known issue when using Prisma with a custom output directory in a monorepo, especially when the generated client and schema are in a different package (here, trpc) than the app making the calls (here, server). Prisma tries to resolve the path to files like query_compiler_bg.wasm or schema.prisma relative to the process's current working directory, which often results in it looking in the wrong place (e.g., apps/server/src/prisma instead of packages/trpc/src/prisma).
Workarounds and Solutions:
1. Manual Copying: Some users have worked around this by manually copying the required files (schema.prisma, .wasm, engine binaries) from the trpc package's output directory into the server app's expected location as part of the build or deploy process. This is tedious but can be automated with scripts. See similar approaches in this discussion.
2. Experimental Webpack Plugin: If you are using Next.js or Webpack, Prisma provides an experimental plugin to ensure the necessary files are copied correctly during the build:
This helps with file resolution in monorepo setups, but may not cover all edge cases, especially with ESM and custom output paths source.
3. Output to node_modules: Some have set the Prisma client output to a shared node_modules path and imported from there, e.g.:
Then import from
There is no official, robust solution for this scenario as of now. Workarounds involve manual file copying, using the experimental Webpack plugin, or adjusting output paths. Monitor the linked issues for updates from the Prisma team. š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
@prisma/client/trpc in your server app. This is a hack and may not be ideal for all setups source.
4. Path Reso
lution Issues: The root cause is Prisma's generated client using process.cwd() to resolve paths, which doesn't work well across package boundaries in monorepos. There is no official fix yet for this with the new queryCompiler/driverAdapters features source.
Summary:There is no official, robust solution for this scenario as of now. Workarounds involve manual file copying, using the experimental Webpack plugin, or adjusting output paths. Monitor the linked issues for updates from the Prisma team. š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
it used to work before i either started using Query Compiler or upgraded to 6.12.0 (i did both at once yesterday), and now it does not š¤
Did you try changing the provider from
prisma-client-js to prisma-client?