PrismaP
Prisma17mo ago
1 reply
luckywatcher42

Generate prisma client programmatically

I tried looking through existing Github issues, discussions, and here in Discord with no success, but I'd like to generate the client package programmatically if possible.

For example, in a Prisma schema file I might have the following block:

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"]
}

...


When I run
prisma generate
the client library is built in node_modules/.prisma/client and importable via
@prisma/client
.

How can I generate the code in node_modules/.prisma/client programmatically?

---

For more context, I ultimately want to override the name of the package name in node_modules/.prisma/client/package.json. I'm thinking of writing a custom generator that wraps prisma-client-js and then renames the
name
field. If all else fails, I can do this in a script instead, but I'd prefer to do it as a generator to make it clear something special is going on.
Was this page helpful?