Search code examples
javascriptnpmnext.jsprismavercel

How to deploy to Vercel with dynamically generated package from Prisma


I'm using Prisma and Vercel. Prisma dynamically generates the Prisma client, but Vercel caches the old client and doesn't rebuild it unless I log in to Vercel and click "redeploy" which forces it to reinstall all the packages.

Is there any way to force this one package to just rebuild every time I push to GitHub, so that Vercel won't use the cached version? I noticed that if I change the package version, it will rebuild, but that's a pretty big hack. Is there some way to flag it to rebuild every time?

"@prisma/client": "3.8.0" // some special flag to prevent this from getting cached?

Solution

  • What command are you using to build the app?

    Recommended approach is to use this one:

    // package.json scripts section
    "vercel-build": "prisma generate && prisma migrate deploy && next build",
    

    It will generate new prisma client and definitions, apply migrations and then build the app for production.

    More info in the docs as always