{"record":{"id":"3deadf2ee2f4eafb","repo":"n8n-io/n8n","slug":"sqlite-package-has-not-been-found-installed-try-t","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/SqliteDriver.ts","lineNumber":184,"sourceCode":"\t\t\tawait run(`PRAGMA busy_timeout = ${this.options.busyTimeout}`);\n\t\t}\n\n\t\t// we need to enable foreign keys in sqlite to make sure all foreign key related features\n\t\t// working properly. this also makes onDelete to work with sqlite.\n\t\tawait run(`PRAGMA foreign_keys = ON`);\n\n\t\treturn databaseConnection;\n\t}\n\n\t/**\n\t * If driver dependency is not given explicitly, then try to load it via \"require\".\n\t */\n\tprotected loadDependencies(): 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 * Auto creates database directory if it does not exist.\n\t */\n\tprotected async createDatabaseDirectory(fullPath: string): Promise<void> {\n\t\tawait mkdirp(path.dirname(fullPath));\n\t}\n\n\t/**\n\t * Performs the attaching of the database files. The attachedDatabase should have been populated during calls to #buildTableName\n\t * during EntityMetadata production (see EntityMetadata#buildTablePath)\n\t *\n\t * https://sqlite.org/lang_attach.html\n\t */\n\tprotected async attachDatabases() {\n\t\t// @todo - possibly check number of databases (but unqueriable at runtime sadly) - https://www.sqlite.org/limits.html#max_attached","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/driver/sqlite/SqliteDriver.ts#L166-L202","documentation":"DriverPackageNotInstalledError('SQLite', 'sqlite3') is thrown from SqliteDriver.loadDependencies when this.options.driver is unset and require('sqlite3') throws. The sqlite3 native module is required for the sqlite driver to function; this fires during connect().","triggerScenarios":"DB_TYPE=sqlite (or options.type='sqlite'/'sqlite-pooled') is configured but the 'sqlite3' package is not resolvable, or its native binding failed to load (often surfaced as a require error).","commonSituations":"An alpine/slim Docker image missing the build toolchain so sqlite3's native binding never compiled; a node version upgrade broke the prebuilt sqlite3 binary; node_modules pruning; a cross-architecture deploy (e.g. arm64 image with only x64 prebuilds).","solutions":["Install sqlite3 in the runtime workspace: 'npm install sqlite3'.","If on an unusual architecture, ensure a prebuilt binary exists or install build tools (python, make, g++) so node-gyp can compile.","Pass options.driver = sqlite3 explicitly to bypass require if your bundling puts sqlite3 somewhere non-standard.","After a Node major upgrade, rebuild native modules (npm rebuild sqlite3)."],"exampleFix":"// before\n// DB_TYPE=sqlite but sqlite3 native module missing -> error\n// after\nnpm install sqlite3\n# if native build fails: npm rebuild sqlite3\n","handlingStrategy":"validation","validationCode":"// At startup, probe that sqlite3 loads on this platform.\nif (config.dbType.startsWith('sqlite')) {\n  try { require('sqlite3'); } catch (e) {\n    throw new Error('sqlite3 native module failed to load: ' + e.message);\n  }\n}\n","typeGuard":null,"tryCatchPattern":"import { DriverPackageNotInstalledError } from '@n8n/typeorm';\ntry {\n  await dataSource.initialize();\n} catch (e) {\n  if (e instanceof DriverPackageNotInstalledError && e.args?.[0] === 'SQLite') {\n    failStartup('SQLite driver needs sqlite3; run npm install sqlite3 && npm rebuild sqlite3');\n  }\n  throw e;\n}\n","preventionTips":["Pin sqlite3 as a hard dependency; rebuild native modules on Node upgrades.","Ensure the deployment image has a prebuilt binary for its arch or a working build toolchain.","Run a smoke test that loads sqlite3 in CI for each target image.","Pass options.driver explicitly if bundling sqlite3 non-standardly."],"tags":["typeorm","sqlite","dependencies","native-module","database","startup"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}