typeorm/typeorm · error · DriverPackageNotInstalledError

Nativescript package has not been found installed. Please ru

Error message

Nativescript package has not been found installed. Please run "npm install nativescript-sqlite".

What it means

Thrown by NativescriptDriver.loadDependencies() when no driver instance was provided. The NativeScript driver expects the nativescript-sqlite module to be injected via the `driver` connection option; if it is absent the DriverPackageNotInstalledError fires, naming the missing npm package.

Source

Thrown at src/driver/nativescript/NativescriptDriver.ts:137

                        [],
                        (err: Error, result: any): any => {
                            if (err) return fail(err)
                            // We are all set
                            ok(db)
                        },
                    )
                },
            )
        })
    }

    /**
     * If driver dependency is not given explicitly, then try to load it via "require".
     */
    protected loadDependencies(): void {
        this.sqlite = this.driver
        if (!this.driver) {
            throw new DriverPackageNotInstalledError(
                "Nativescript",
                "nativescript-sqlite",
            )
        }
    }
}

View on GitHub (pinned to df07bf1ef4)

Solutions

  1. Run npm install nativescript-sqlite in your NativeScript project.
  2. Pass the driver explicitly in options: new DataSource({ type: 'nativescript', driver: require('nativescript-sqlite'), database: 'app.db' }).
  3. Verify the module resolves from your bundle (webpack/metro config) before constructing the DataSource.

Example fix

// before
const ds = new DataSource({ type: 'nativescript', database: 'app.db' });
await ds.initialize();

// after
const sqlite = require('nativescript-sqlite');
const ds = new DataSource({ type: 'nativescript', database: 'app.db', driver: sqlite });
await ds.initialize();
Defensive patterns

Strategy: validation

Validate before calling

const sqlite = require('nativescript-sqlite');
if (!sqlite) throw new Error('nativescript-sqlite not installed');
const ds = new DataSource({ type: 'nativescript', database: 'app.db', driver: sqlite });
await ds.initialize();

Type guard

function hasNativescriptDriver(opts: { driver?: any }): opts is { driver: NonNullable<any> } {
  return opts.driver != null;
}

Prevention

When it happens

Trigger: Creating a DataSource with type 'nativescript' without supplying the driver option (this.driver) and without the nativescript-sqlite package resolvable in the project. The check at line 135-136 sets this.sqlite = this.driver then throws if falsy.

Common situations: Developing a NativeScript app where nativescript-sqlite was not installed or the require path changed. Forgetting to pass { driver: require('nativescript-sqlite') } in the connection options.

Related errors


AI-assisted analysis of typeorm/typeorm@df07bf1ef4 (2026-08-07). Data as JSON: /api/errors/331a1114d49c8183. Report an issue: GitHub.