#**Package better-sqlite3 with my electron app for Windows (Electron-Forge)

4 messages · Page 1 of 1 (latest)

midnight ravine
#

also, there are no errors when I run the application before packaging, it is completely operational before and crashes only when packaged.

#

**Package better-sqlite3 with my electron app for Windows (Electron-Forge)

unkempt stirrup
#

I use better-sqlite3 in my app, but I use Drizzle ORM so I can probably only partially help you. When you make/package the application the path changes. So first you need to check if you are in production or development mode. You can do that by

import { app } from "electron";

const isProduction = app.isPackaged;

Then you need to set the paths for production and development. Here is a similar example of what you can do:

const sqlitePath = isProduction
? process.resourcesPath + "/sqlite"
: "sqlite";

Then in your forge.config.ts file:

const config: ForgeConfig = {
packagerConfig: {
asar: true,
extraResource: ["./sqlite"],
}, ...

Try this. I highly recommend using Drizzle ORM. I hope this helped

hushed swallow