{"id":"0d822f7c22527ded","repo":"typeorm/typeorm","slug":"capacitor-package-has-not-been-found-installed-pl","errorCode":null,"errorMessage":"Capacitor package has not been found installed. Please run \"npm install @capacitor-community/sqlite\".","messagePattern":"Capacitor package has not been found installed\\. Please run \"npm install @capacitor-community/sqlite\"\\.","errorType":"exception","errorClass":"DriverPackageNotInstalledError","httpStatus":null,"severity":"critical","filePath":"src/driver/capacitor/CapacitorDriver.ts","lineNumber":104,"sourceCode":"\n        if (\n            this.options.journalMode &&\n            [\"DELETE\", \"TRUNCATE\", \"PERSIST\", \"MEMORY\", \"WAL\", \"OFF\"].indexOf(\n                this.options.journalMode,\n            ) !== -1\n        ) {\n            await connection.execute(\n                `PRAGMA journal_mode = ${this.options.journalMode}`,\n            )\n        }\n\n        return connection\n    }\n\n    protected loadDependencies(): void {\n        this.sqlite = this.driver\n        if (!this.driver) {\n            throw new DriverPackageNotInstalledError(\n                \"Capacitor\",\n                \"@capacitor-community/sqlite\",\n            )\n        }\n    }\n}\n","sourceCodeStart":86,"sourceCodeEnd":111,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/driver/capacitor/CapacitorDriver.ts#L86-L111","documentation":"Thrown as DriverPackageNotInstalledError by CapacitorDriver.loadDependencies when this.driver is falsy — i.e. no @capacitor-community/sqlite connection instance was supplied via the DataSource `driver` option. The Capacitor driver does not auto-require; it expects the caller to hand in the configured SQLiteConnection from the plugin, so an absent instance is a setup error.","triggerScenarios":"Creating a DataSource with type 'capacitor' but omitting options.driver; initializing before the Capacitor plugin's SQLiteConnection is instantiated; running TypeORM in a non-Capacitor environment without providing a mock driver.","commonSituations":"Mobile app bootstrap order (plugin not ready before DataSource init); web/desktop builds that don't register @capacitor-community/sqlite; tutorial code copied without wiring the plugin.","solutions":["Install and configure the plugin: npm install @capacitor-community/sqlite, then instantiate SQLiteConnection and pass it as DataSource option `driver`.","Ensure plugin customUrl/permissions setup (iOS/Android) completes before building the DataSource.","If unit-testing outside Capacitor, inject a stub driver object that implements the methods you call."],"exampleFix":"// before\nnew DataSource({ type:'capacitor', database:'app.db' /* no driver */ })\n\n// after\nimport { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite'\nconst sqlite = new SQLiteConnection(CapacitorSQLite)\nnew DataSource({ type:'capacitor', database:'app.db', driver: sqlite })","handlingStrategy":"validation","validationCode":"// Ensure the plugin instance is provided before init\nif (!options.driver) throw new Error('Capacitor SQLiteConnection missing — pass options.driver')","typeGuard":"const hasCapacitorDriver = (o: any): boolean => !!o?.driver","tryCatchPattern":null,"preventionTips":["Instantiate SQLiteConnection from @capacitor-community/sqlite before DataSource init.","Pass it via the `driver` option.","In tests, inject a stub driver."],"tags":["capacitor","dependency","mobile","setup","typeorm"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}