@jdansercoer I've found a workaround for this problem.
I use manual deployments via server code uploading in UI.
By default prisma generate
creates client code in node_modules/.prisma/client
and @prisma/client
expects to find client and types there. If client is not generated you see this error Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
.
It's possible to change default location for generated code to allow prisma to load it from there. This is what I use to include generated client to my src
folder which will be included into final build
which I upload in UI.
generator client {
provider = "prisma-client-js"
output = "../src/db/client"
binaryTargets = ["native", "debian-openssl-1.1.x"]
}
Note: make sure to import your client from generated code (import { PrismaClient } from "../db/client";
by providing generated Prisma client outside of node_modules/
you make it unnecessary to run use postinstall
script.
General solution:
- Change Prisma config to store generated client outside of
node_modules
- Change imports to point directly to generate client.
- Make sure to include generated client into deployment. E.g. include
yarn copyfiles -u 1 \"src/db/**/*\" ./build
into build step.