3 Replies
Prisma AI Help
Prisma AI Help•6d ago
You selected the bot's instantaneous insights. Let me compile your answer right away! Yes, several users have reported similar issues with Turborepo and Prisma, especially in monorepo setups. The error Error: Cannot find module .../node_modules/src/node_modules/prisma/build/index.js or similar "Cannot find module" errors often occur due to how dependencies and generated Prisma Client files are resolved in monorepos. Common causes and workarounds from the knowledge sources: 1. Prisma Client Location:
If your Prisma Client is generated in a package (e.g., packages/prisma), but your app (e.g., apps/web) tries to import it, you must ensure the generated client is accessible from the consuming package. Sometimes, Prisma Client files end up in the wrong node_modules folder, causing resolution issues.
- Make sure you run prisma generate in the correct directory and that the output path matches your import statements.
- Avoid generating the client directly inside node_modules/@prisma/client in custom locations, as this can cause module resolution problems. Instead, generate it in a dedicated directory and import from there, e.g., import { PrismaClient } from '@myorg/prisma-client' if you set the output accordingly see example. 2. pnpm and postinstall scripts:
If you use pnpm v10+, postinstall scripts (like Prisma's client generation) may not run by default. You need to approve them in your package.json:
"pnpm": {
"onlyBuiltDependencies": [
"@prisma/client"
]
}

"pnpm": {
"onlyBuiltDependencies": [
"@prisma/client"
]
}

Or run pnpm approve-builds manually. Also, always run prisma generate before your build process, especially in CI/CD details here. 3. Inconsistent builds on Vercel:
Some users report that builds may work intermittently on Vercel. This can be due to caching or race conditions in dependency installation and client generation. Adding explicit prisma generate steps and ensuring all dependencies ar e installed in the correct workspace can help see discussion. If you provide more details about your monorepo structure and where your Prisma schema and generated client live, I can help with more targeted advice. šŸ¤” 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.
shubhamxshah
shubhamxshahOP•6d ago
Fixed it, There wasn't a build script which is why it was throwing error.
Nurul
Nurul•4d ago
Glad to hear that you were able to solve it šŸ™Œ

Did you find this page helpful?