Prisma "Unable to require libquery_engine" (libssl/musl on Alpine) in CI
On Alpine the Prisma Query Engine is the linux-musl build and it dynamically links OpenSSL. Alpine ships without libssl by default, so the engine cannot load and the client fails to initialize.
What this error means
On an Alpine (musl) runner or image the client throws "Unable to require(.../libquery_engine-linux-musl.so.node)" mentioning libssl.so, or "Error loading shared library libssl.so.1.1: No such file or directory".
PrismaClientInitializationError: Unable to require(`/app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node`).
Error loading shared library libssl.so.1.1: No such file or directory (needed by /app/node_modules/.prisma/client/libquery_engine-linux-musl.so.node)Common causes
Alpine has no OpenSSL installed
The musl engine links libssl at load time, but a minimal Alpine image does not include openssl, so the shared library is missing.
The musl binaryTarget was not generated
If the client was generated without linux-musl in binaryTargets, the Alpine-compatible engine is absent entirely.
How to fix it
Install OpenSSL and generate for musl
- Install
openssl(and libc6-compat where needed) in the Alpine image. - Add
linux-musl-openssl-3.0.x(orlinux-musl) tobinaryTargets. - Run
prisma generateso the musl engine is produced.
RUN apk add --no-cache openssl
# schema.prisma:
# binaryTargets = ["native", "linux-musl-openssl-3.0.x"]Use a glibc base image instead
Switching to a Debian slim image avoids the musl/openssl mismatch, using the debian-openssl engine.
FROM node:20-slim
RUN apt-get update && apt-get install -y opensslHow to prevent it
- Install openssl in Alpine images that run Prisma.
- Include the musl binaryTarget when you deploy or test on Alpine.
- Prefer a glibc base image if you do not need Alpine.