Anyone have an experience distributing a library w...
# orm-help
y
Anyone have an experience distributing a library with Prisma. How do you pack your Prisma client in distribution?
I am trying to create a general data access library to use in more than one application. But when I install my library to the target application I am receiving an exception like below.
Copy code
Query engine binary for current platform "darwin" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/query-engine-darwin")
Do I need to also install prisma to my target application (the application that I use my Prisma based library)?
b
have you tried including multiple targets like this for both dev and prod environments with the binary targets, we are doing something similar
Copy code
generator client {
  provider      = "prisma-client-js"
  output        = "../generated/client"
  binaryTargets = ["darwin", "linux-musl"]
}
👍 1
e
If I remember correctly, declaring multiple targets will generate binary for both of them i.e. increasing the final bundle 🙂 If you can work around environment variables, you can set an environment var like this and generate the target based on where you want to run prisma
Copy code
generator client {
  ...
  binaryTargets = [env("PRISMA_BINARY_TARGET")]
}
👍 2
n
@Yilmaz Ugurlu did you get this resolved? I think Eddy's approach to making this dynamic via an environment variable looks promising! You can also read more about binary targets in the docs here. Let me know if you have any further question, always happy to help 🙂
You might also want to check out how the folks from next-auth are dealing with this, since they should have a similar problem 🙂
y
@nikolasburk thanks for the suggestion. I managed to get it working. I copied my prisma file to the
/dist
folder in the build phase and also added additional binary targets. That fixed the problem for me.
👌 1
one more thing, in development, if you link your package with yarn to your main app it triggers that error again. I used
npm link
and it has resolved.
@Eddy Nguyen thank you for your suggestion, I’ll try this in testing deployment shortly.