Published on

How to fix "@prisma/client did not initialize yet" in Vercel

Authors

If you've manually set up Prisma then chances are you might have missed configuring prebuild for Prisma which might cause issues during build in environments like Vercel.

The fix is straightforward,

Just add npx prisma generate as prebuild in your root package.json script.

{
    "scripts":{
        "build":"next build",
        "prebuild":"npx prisma generate"
    }
}

We can also add it postinstall as well which will run prisma generate command right after the npm install

{
    "scripts":{
        "postinstall":"npx prisma generate"
    }
}

What does it pre* or post* npm command does?

It basically, runs our command before/after the particular npm command.

Happy fixing Prisma!