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

10 messages · Page 1 of 1 (latest)

primal quartzBOT
#

You've gone full bot mode! Let me fetch that AI answer for you ASAP.

primal quartzBOT
# primal quartz You've gone full bot mode! Let me fetch that AI answer for you ASAP.

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)
      
      (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

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...

primal quartzBOT
# primal quartz You've gone full bot mode! Let me fetch that AI answer for you ASAP.

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.

primal quartzBOT
hearty abyss
#

We don't have an official example of Prisma with Electron.
Are you trying the latest prisma version?

hearty abyss
#

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.

finite drift
finite drift