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
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model orders {
id Int @id @default(autoincrement())
product String
quantity Int
createdAt DateTime @default(now())
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model orders {
id Int @id @default(autoincrement())
product String
quantity Int
createdAt DateTime @default(now())
}
lib/prisma.ts
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export default prisma;
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export default prisma;
pages/api/orders.ts
import prisma from '../../lib/prisma';

export default async function handler(req, res) {
const newOrder = await prisma.orders.create({
data: {
product: 'Apple',
quantity: 5
}
});
res.status(200).json(newOrder);
}
import prisma from '../../lib/prisma';

export default async function handler(req, res) {
const newOrder = await prisma.orders.create({
data: {
product: 'Apple',
quantity: 5
}
});
res.status(200).json(newOrder);
}
.env
DATABASE_URL="postgresql://user:pass@host:5432/db"
DATABASE_URL="postgresql://user:pass@host:5432/db"
tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["pages", "lib"],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["pages", "lib"],
"exclude": ["node_modules"]
}
3 Replies
Prisma AI Help
Prisma AI Help15h ago
You chose to compile with the bot. One moment while I piece together your answer…
Prisma AI Help
Prisma AI Help15h ago
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 package.json:
"scripts": {
"postinstall": "prisma generate"
}
"scripts": {
"postinstall": "prisma generate"
}
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 Path
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:
generator client {
provider = "prisma-client-js"
output = "./prisma/generated/client"
}
generator client {
provider = "prisma-client-js"
output = "./prisma/generated/client"
}
Then your import should be:
import { PrismaClient } from '../../prisma/generated/client';
import { PrismaClient } from '../../prisma/generated/client';
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 References
The 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 Version
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
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
Prisma AI Help
Prisma AI Help15h ago
/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.

Did you find this page helpful?