Prisma Client module not found after packaging it on Electron-forge

Has anyone ever succeed packaging electron-forge with vite template with prisma orm I'ts giving me headaches.
No description
6 Replies
Prisma AI Help
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
Prisma AI Help
Short answer: Yes. The common fixes are to keep Prisma’s generated client and engines out of ASAR and ensure Electron’s packaged paths include them. Here are approaches that worked for others using Electron Forge/Vite/Webpack: What to do - Generate Prisma Client before packaging: npx prisma generate (packaging won’t generate it) (ASAR answer). - Ship Prisma artifacts via extra resources (don’t bundle into ASAR): - Electron Builder/Forge: copy node_modules/.prisma (and your SQLite DB) into resources. Examples: - electron-builder: - extraResources: include node_modules/.prisma and your db file (examples, discussion). - asarUnpack: ["*/.{node,dll}", "node_modules/.prisma/client"] to allow native engine loading (issue). - Electron Forge + Webpack: exclude .prisma from asset relocator so it’s copied as-is, and add extraResource entries to package it (fix). - Ensure Prisma finds the schema/engines at runtime: - In production, Electron may add a resources directory or move paths. Some users chdir to process.resourcesPath when app.isPackaged so Prisma’s fallbacks hit the copied .prisma folder:
import { app } from 'electron'
if (app.isPackaged) process.chdir(process.resourcesPath)

import { app } from 'electron'
if (app.isPackaged) process.chdir(process.resourcesPath)

(Works with extraResources + asarUnpack) (issue). - If engines are unpacked outside ASAR, you can explicitly point Prisma to the engine binary (discouraged to rely on __internal, but possible) or set PRISMA_QUERY_ENGINE_LIBRARY to the full path to the .node file ([guidance](<https://github.com/prisma/prisma/issues/7630#issuecomment-88497
GitHub
Prisma Client not finding query-engine after electron packages ever...
So im making a project using electron and prisma (within others that we dont have to worry about) and i am trying to solve this error for hours, i cant get prisma to find the query-engine executabl...
Prisma AI Help
2727>), env var fix). - Do not run Prisma in the renderer; run it in the main process and communicate via IPC. Prisma cannot run in the browser context (official answer). Known pitfalls - Executables inside ASAR can’t be spawned. Ensure electron-builder unpacks Prisma engines into app.asar.unpacked and that paths are adjusted (binaryPath or env var) if needed (official answer). - Electron Forge may place files under resources/.prisma. If Prisma expects them in .prisma at cwd, copy them there (CopyWebpackPlugin) or adjust working dir as above (issue). If you share your exact Forge/Vite config, I can map the minimal changes from the examples above. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul21h ago
We don't have an official example of Prisma with Electron. Are you trying the latest prisma version?
vandroid
vandroidOP21h ago
yes
Nurul
Nurul20h ago
Is your repository open source? It's difficult to predict what might be going wrong. The AI bot provided correct Electron related conversations from our repository.

Did you find this page helpful?