I'm making a project using Electron and Prisma (along with others that we don't have to worry about). I've been trying to solve this error for hours: I can't get Prisma to find the query-engine executable, and I've tried a bunch of things I found on internet, but still nothing.
I tryed to set where Prisma will find the query-engine, this repo i found the "solution", but it did not work (at least not for me):
This is my Prisma schema:
datasource db {
provider = "sqlite"
url = "file:./data.db"
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
output = "../electron/database/generated/client"
}
I am using webpack to compile both Electron and React, so I set the schema generate to the Electron folder that webpack will then compile to the "dist" folder. I used the copy-webpack-plugin to copy both schema.prisma and the query-engine-windows.exe (which is my OS). After all that I get this error:
r [PrismaClientKnownRequestError]: spawn C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar.unpacked\dist\query-engine-windows.exe ENOENT
at C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:69:77852
at c (C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:1:54711)
at Generator._invoke (C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:1:54464)
at Generator.throw (C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:1:55070)
at asyncGeneratorStep (C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:1:195068)
at s (C:\Users\Tiago Oliveira\programming\web-dev\electron-prisma-react-ts-passwordkeeper\packages\win-unpacked\resources\app.asar\dist\main.js:1:195340)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 'ENOENT',
clientVersion: '2.24.1',
meta: undefined
}
event using this setup to get the app path and setting the path exactly where the qe (query-engine) is it says its not there...?
import { app } from "electron"
import path from "path"
const qePath = path.join(
app.getAppPath().replace("app.asar", "app.asar.unpacked"),
"dist/query-engine-windows.exe"
)
const prisma = new PrismaClient(process.env.NODE_ENV === "production" ? {
__internal: {
engine: {
binaryPath: qePath
}
}
} : {})
And to make sure I wasn't crazy, I took the path it said wasn't there and threw it to the console and it ran! So something is wrong here.
If you have any questions about how the files look, you can check at this project repo.
If you want to get the error and try out yourself to get the error, just clone the repo and do yarn and run "yarn package:exe"m, which will compile the main folder which is Electron, and then the src folder which is React, and right after that it will bundle it for Electron and then execute it right away: yarn package:exe
will webpack-(all)>electron->execute.