{"record":{"id":"603d3949cc08bc33","repo":"n8n-io/n8n","slug":"sqlite-package-has-not-been-found-installed-try-t-603d39","errorCode":null,"errorMessage":"SQLite package has not been found installed. Try to install it: npm install sqlite3 --save","messagePattern":"SQLite package has not been found installed\\. Try to install it: npm install sqlite3 --save","errorType":"exception","errorClass":"DriverPackageNotInstalledError","httpStatus":null,"severity":"critical","filePath":"packages/@n8n/typeorm/src/driver/sqlite-pooled/SqliteLibrary.ts","lineNumber":42,"sourceCode":"\t */\n\tpublic sqlite: sqlite3;\n\n\t/**\n\t * Any attached databases (excepting default 'main')\n\t */\n\tpublic attachedDatabases: DatabasesMap = new Map();\n\n\tconstructor(private readonly options: SqlitePooledConnectionOptions) {}\n\n\t/**\n\t * If driver dependency is not given explicitly, then try to load it via \"require\".\n\t */\n\tpublic loadLibrary(): void {\n\t\ttry {\n\t\t\tconst sqlite = this.options.driver || require('sqlite3');\n\t\t\tthis.sqlite = sqlite.verbose();\n\t\t} catch (e) {\n\t\t\tthrow new DriverPackageNotInstalledError('SQLite', 'sqlite3');\n\t\t}\n\t}\n\n\t/**\n\t * Creates connection with the database.\n\t *\n\t * @param {number} flags Flags, such as SQLITE_OPEN_READONLY, to pass to the sqlite3 database connection\n\t */\n\tpublic async createDatabaseConnection(flags?: number): Promise<Sqlite3Database> {\n\t\tif (this.options.flags === undefined || !(this.options.flags & this.sqlite.OPEN_URI)) {\n\t\t\tawait this.createDatabaseDirectory(this.options.database);\n\t\t}\n\n\t\tconst databaseConnection: Sqlite3Database = await new Promise((ok, fail) => {\n\t\t\tif (this.options.flags === undefined && flags === undefined) {\n\t\t\t\tconst connection = new this.sqlite.Database(this.options.database, (err: any) => {\n\t\t\t\t\tif (err) return fail(err);\n\t\t\t\t\tok(connection);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/driver/sqlite-pooled/SqliteLibrary.ts#L24-L60","documentation":"SqliteLibrary.loadLibrary() tries to resolve the native `sqlite3` package via require(); if that throws (module not found or failed to load native bindings) it rethrows as DriverPackageNotInstalledError('SQLite','sqlite3'). The DataSource cannot open any connection until this succeeds, so this fails at boot.","triggerScenarios":"Constructing/initializing a SQLite DataSource when the `sqlite3` npm package is not installed, is not resolvable from the running module's node_modules, or its native binding failed to compile/load for the current Node/ABI/arch.","commonSituations":"Missing dependency after a fresh clone, a botched `pnpm install`, Node version upgrade breaking the prebuilt sqlite3 binary, missing build toolchain forcing a failed source build, or a bundler/frozen-lockfile install that skipped optional native deps.","solutions":["Install the dependency: `pnpm add sqlite3` (or the workspace-appropriate install command).","Re-run a clean install: remove node_modules and lockfile-state, then `pnpm install`.","Ensure the Node version matches a sqlite3 release with prebuilt binaries, or install the build toolchain (python, make, C++ compiler) so the native addon can compile.","If passing a custom driver via options.driver, make sure that object is a working sqlite3 module."],"exampleFix":"// before — sqlite3 missing from node_modules\nconst ds = new DataSource({ type: 'sqlite', database: './db.sqlite' });\nawait ds.initialize(); // throws DriverPackageNotInstalledError\n\n// after\n// $ pnpm add sqlite3\nconst ds = new DataSource({ type: 'sqlite', database: './db.sqlite' });\nawait ds.initialize();","handlingStrategy":"validation","validationCode":"function sqlite3Available(): boolean {\n  try {\n    require.resolve('sqlite3');\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nif (!sqlite3Available()) {\n  throw new Error('sqlite3 is not installed. Run: pnpm add sqlite3');\n}\nawait dataSource.initialize();","typeGuard":"import { DriverPackageNotInstalledError } from '@n8n/typeorm';\n\nfunction isDriverPackageNotInstalledError(e: unknown): e is DriverPackageNotInstalledError {\n  return e instanceof DriverPackageNotInstalledError;\n}","tryCatchPattern":"try {\n  await dataSource.initialize();\n} catch (e) {\n  if (e instanceof DriverPackageNotInstalledError) {\n    console.error(`Missing native driver. Install it: ${e.message}`);\n  }\n  throw e;\n}","preventionTips":["Keep sqlite3 in package.json dependencies.","After a fresh clone, run a full install before initializing a DataSource.","Match your Node version to a sqlite3 release with prebuilt binaries, or provide a build toolchain.","Don't bundle/freeze-lockfile away native optional deps."],"tags":["database","dependencies","sqlite","bootstrap"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}