Prisma+monorepo+esbuild = no binary

Site ID: deductive-api-staging

Hi there,

I have a typescript express API in a monorepo at /apps/server
I am using node20 (20.10.0 in my .nvmrc)
I can build and deploy my app and I can get a response from my app when I access it, but I see errors:

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x".\n\nThis is likely caused by a bundler that has not copied "" next to the resulting bundle.\nEnsure that "" has been copied next to the bundle or in "…/…/node_modules/.prisma/client"

My esbuild script copies the correct binary from my monorepo’s node_modules to the function folder:

  resolveFrom: 'cwd',
  assets: {
    from: ['./../../node_modules/.prisma/client/'],
    to: ['./netlify/functions/api/'],

I can see the file in the function build folder when I run this locally.

Despite this, the prisma client says it can’t find the file on production. I have tried all kinds of permutations here to try to resolve it, but to no avail. In my netlify,toml, under functions, I have:

included_files = ["./netlify/functions/api/"]

This has made no difference. I’ve tried various ways of writing the path.

Can anyone help? I’d be very grateful.

Many thanks.

PS: Everything works with netlify dev.

Furthermore, if I list the files in the deployed function directory, I can see that the binary that it says it can’t find is there. Is this potentially a permissions problem? How can I give the binary execute permissions?

Fixed: I needed to place the binary adjacent to the function folder, not in the function folder. A ‘folderless function’ was no good. Ah, that was a long day, figuring that out.