Prisma Files too large to upload

The prisma generated files are almost 46M+ in node_modules. However after bundling, it becomes 20M. According to open-next documentation, we have to add @prisma/client in next.config.ts. But due to the large size of prisma it fails to upload to cloudflare workers. (I ensured it by adding and removing @prisma/client from next.config.ts). Any suggestion to reduce the size of prisma generated files? I am using a driverAdapter and a neon database
5 Replies
Prisma AI Help
Prisma AI Help5mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away!
Prisma AI Help
Prisma AI Help5mo ago
You're encountering a common issue: Prisma's bundle size can easily exceed Cloudflare Workers' strict limits (1MB for free, 3MB for paid plans) when using @prisma/client, especially with driver adapters like Neon. This is due to the inclusion of large engine files and duplicated dependencies in node_modules, even after bundling. Key suggestions from the knowledge sources: 1. Cloudflare Workers Size Limits: Prisma ORM often exceeds the free plan's 1MB (or even the 3MB paid) limit. The official recommendation is to upgrade to a paid plan or use Prisma Accelerate, but even then, size can be a challenge if your app is non-trivial. If you can't upgrade, you may need to consider alternative ORMs for Cloudflare Workers, as some users have done Deploy to Cloudflare Workers, Cloudflare dashboard discussion. 2. Manual Pruning: You can try to manually remove unnecessary files from node_modules before bundling. For serverless/edge deployments, only @prisma/client and .prisma/client are strictly needed. The prisma CLI package and extra engine binaries can be removed. Some users have achieved significant reductions by deleting node_modules/prisma, node_modules/.bin, and unnecessary engine files Github Issue 19358, Github Issue 7520. 3. Custom Output Path: Generating Prisma Client to a custom output folder and only including that in your bundle can help, but you must adjust your imports accordingly. This can sometimes avoid duplicated files Github Issue 21628. 4. Recent Improvements: Prisma 4.8.0+ has reduced engine sizes by ~50%, but for edge environments, the bundle may still be too large [Github Issue 14691](<https://github.com/prisma/
GitHub
Prisma
Prisma makes working with databases easy. Prisma has 164 repositories available. Follow their code on GitHub.
Prisma AI Help
Prisma AI Help5mo ago
prisma/issues/14691>). Summary:
For Cloudflare Workers, even with aggressive pruning, Prisma's size is often too large for the free tier. You can try removing unnecessary files and only bundling the minimal client, but if you still exceed the limit, you may need to consider a different ORM or upgrade your Cloudflare plan. There is currently no official, fully automated way to make Prisma fit comfortably within the strictest Cloudflare Workers limits.
Kas Roudra
Kas RoudraOP5mo ago
Which files are safe to remove in an edge environment?
Prisma AI Help
Prisma AI Help5mo ago
✅ Great, thanks for letting us know that this solved your question!

Did you find this page helpful?