Search code examples
npmprismaelectron-builder

How to build Prisma Windows electron app on Linux?


What we want to achieve is to build linux and windows installers for our Electron app on our (Linux) build server.

After installing Wine, this basically works, except for Prisma:

i.e. Prisma relies on OS-specific binaries - thus, we must have the correct binaries available for each platform.

Prisma Query engine / Prisma Client

This part works: we set the binaryTarget to our target platforms: binaryTargets = ["windows", "debian-openssl-1.1.x"].
When we now generate the client (prisma generate), the target dir (node_modules/.prisma/client/) contains the query-engines for linux and windows: libquery_engine-debian-openssl-1.1.x.so.node, query_engine-windows.dll.node

Prisma Migration Engine

i.e. in package.json we only specify the prisma dependency and npm will only install the binaries for the current OS in node_modules/@prisma/engines/, i.e.: libquery_engine-debian-openssl-1.1.x.so.node, migration-engine-debian-openssl-1.1.x

How can we get npm to install both migration Engines (i.e. for Windows and Linux)?


Solution

    • set the PRISMA_CLI_BINARY_TARGETS accordingly: e.g. PRISMA_CLI_BINARY_TARGETS=darwin,rhel-openssl-1.0.x npm install
    • then start npm install
    • and now the binaries for all specified operating systems should exist in node_modules/@prisma/engines
      • in my case, this did not work initially
      • after deleting node_modules/@prisma/engines and starting npm install again, it worked