Craig Glennie

Fixing Prisma “Library may be corrupt” error in Docker container

I have been working on deploying a TRPC / NextJS application to an AWS EKS (Kubernetes) cluster. Though the application started just fine, I was running into this error from Prisma.

PrismaClientInitializationError: Unable to load Node-API Library from /app/node_modules/.prisma/client/, Library may be corrupt

I was a little surprised to see this, because I had been careful to include the right library in my binaryTargets

binaryTargets = ["native", "debian-openssl-1.1.x"]```

And I had also confirmed (though it was fairly obvious from the error message) that the library file did exist in the expected location.

I thought the issue might be related to the AWS-provided AMI for EKS worker nodes, but that didn’t seem to be the problem.

On a hunch, I changed the final step of my Dockerfile so that I wasn’t trying to build an image on a distroless base (which I had been doing because it produces nice tiny images).

FROM node:16

To my surprise, this fixed the problem. I’m not sure what it is about the distroless images that makes Prisma not work, and unfortunately it comes with a much larger image size. But at least I know where the problem is now, and I do have a working container.

I had the same error with node:16-slim, so the differences between regular and slim might be some clue as to the problem.