PunchedYou
PunchedYou
KKysely
Created by PunchedYou on 1/29/2024 in #help
SQLite__namespace is not a constructor
Hi Im building a Electron-Vite App and running into the following error:
TypeError: SQLite__namespace is not a constructor
at Object.<anonymous> (C:\Users\USER\OneDrive\Dokumente\Programmieren\dim_wishlist_2\out\main\index.js:26:13)
at Module._compile (node:internal/modules/cjs/loader:1271:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
at Module.load (node:internal/modules/cjs/loader:1126:32)
at Module._load (node:internal/modules/cjs/loader:967:12)
at l._load (node:electron/js2c/asar_bundle:2:13642)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
TypeError: SQLite__namespace is not a constructor
at Object.<anonymous> (C:\Users\USER\OneDrive\Dokumente\Programmieren\dim_wishlist_2\out\main\index.js:26:13)
at Module._compile (node:internal/modules/cjs/loader:1271:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
at Module.load (node:internal/modules/cjs/loader:1126:32)
at Module._load (node:internal/modules/cjs/loader:967:12)
at l._load (node:electron/js2c/asar_bundle:2:13642)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
I think it has something to do with the import statement of better-sqlite3
import { Database } from '@shared/databaseTypes'
import * as SQLite from 'better-sqlite3'
import { Kysely, SqliteDialect } from 'kysely'

const dialect = new SqliteDialect({
database: new SQLite('../../../resources/database.sqlite3')
})

export const db = new Kysely<Database>({
dialect
})
import { Database } from '@shared/databaseTypes'
import * as SQLite from 'better-sqlite3'
import { Kysely, SqliteDialect } from 'kysely'

const dialect = new SqliteDialect({
database: new SQLite('../../../resources/database.sqlite3')
})

export const db = new Kysely<Database>({
dialect
})
I am using TS and the error gets thrown in the built JS file so I couldn't really figure it out. If you need more details to help me pls let me know.
8 replies