I am using Prisma (sqlite DB) with an Electron + Angular app
Everything works fine until I try to create a record
I’m getting this error in console few times repeated
Here is a part of my schema.prisma file:
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native","darwin","debian-openssl-1.1.x","linux-musl"]
}
I’ve tried using the same Prisma config with a scratch TS project and it works fine
When I’ve tried it with electron I was getting errors
As I understand it cannot find query engine binaries, but I don’t know how to say to Electron where to get them from
2
Answers
Hi
I too had similar problem with prisma.
The issue is that the custom prisma client along with the downloaded binaries for the platform of use gets generated in
node_modules/.prisma
folder (default).when webpack bundled the code,
.prisma
folder wasn’t included with the generated app.asar package innode_modules
folder and thus prisma client couldn’t be loaded along with the binaries.Solution
I changed the output path of the generated prisma client as per prisma doc
and included in my
database.js
file (located insidedatabase
folder) as followsAs the downloaded binaries are also placed indside the
output
folder, there was no problem for prisma client in finding it.I had the same issue when using
electron-builder
to build native binaries.In my case I had to add
.env
file to the build block onpackage.json
and change theoutput
path as spc mentioned.