Vercel Build Failing with Prisma + Supabase + Next.js API Routes
Hey, I'm deploying a backend-only Next.js project using API routes (no frontend) with Prisma (connected to Supabase), and everytime there's build failures on Vercel. Everything works locally, but Vercel throws errors like: -
@prisma/client has no exported member 'PrismaClient'
Cannot find module 'express'
npm run build exited with code 1
I’ve already tried:npx prisma generate
works, Installed all needed deps (@prisma/client
, prisma
, typescript
, etc.), Set CI=false
in Vercel env vars, Cleaned project structure and removed old Express files. Still getting the build error. Any idea what I might be missing?
Here’s what I’ve got: schema.prisma
lib/prisma.ts
pages/api/orders.ts
.env
tsconfig.json
3 Replies
You chose to compile with the bot. One moment while I piece together your answer…
Your issue is likely related to how Prisma Client is generated and imported during the Vercel build process. Here are the most common causes and solutions based on the knowledge sources:
1. Prisma Client Generation
Vercel aggressively caches dependencies, which can result in an outdated or missing Prisma Client. Ensure you have the following in your
If you use a custom output path for the Prisma Client in your schema, you must import from that path. For example, if your generator block is: Then your import should be: If you keep the default, your import is correct as
The error
If you are using Prisma Client 5, ensure your TypeScript version is 5.0 or higher, as older versions are incompatible [Deploy a Fullstack App](<https://github.com/prisma/prisma
Vercel aggressively caches dependencies, which can result in an outdated or missing Prisma Client. Ensure you have the following in your
package.json
:
This ensures Prisma Client is generated during the Vercel build. If you see errors like @prisma/client has no exported member 'PrismaClient'
, it often means the client was not generated or is out of sync with your schema. Also, make sure both prisma
and @prisma/client
are installed and up-to-date in your dependencies, not just devDependencies, to avoid missing binaries during build and runtime on Vercel Deploy to Vercel.
2. Custom Output PathIf you use a custom output path for the Prisma Client in your schema, you must import from that path. For example, if your generator block is: Then your import should be: If you keep the default, your import is correct as
import { PrismaClient } from '@prisma/client';
Vercel - Error: @prisma/client did not initialize yet.
3. Remove Express ReferencesThe error
Cannot find module 'express'
suggests you may have leftover code or dependencies referencing Express. Double-check your codebase and dependencies to ensure no Express code is being imported or required.
4. TypeScript VersionIf you are using Prisma Client 5, ensure your TypeScript version is 5.0 or higher, as older versions are incompatible [Deploy a Fullstack App](<https://github.com/prisma/prisma
GitHub
GitHub - prisma/prisma: Next-generation ORM for Node.js & TypeScrip...
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - prisma/prisma
/discussions/21526>).
If you follow these steps and still encounter issues, please provide the full Vercel build log for more targeted help.
🤔 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.