In Node.js, tile and image rendering is powered by CanvasKit — a WebAssembly build of the Skia graphics library. Before calling GeoPackageManager.open or GeoPackageManager.create, you must tell the library where to find canvaskit.wasm.
The WASM file is bundled with the package at dist/canvaskit/canvaskit.wasm. If you bundle your application or deploy to a non-standard directory, copy that directory to your output path and update the string above to match.
setCanvasKitWasmLocateFile must be called before the first call to GeoPackageManager.open or GeoPackageManager.create. Calling it afterward has no effect because the WASM module is only initialized once.
The package ships a UMD browser bundle at dist/geopackage.min.js. Add it to your HTML with a <script> tag. This exposes a window.GeoPackage global that contains all exported classes and functions.
In the browser, SQLite access is provided by sql.js (compiled to WebAssembly). You must tell the library where to load sql-wasm.wasm from before opening a GeoPackage.
const { setSqljsWasmLocateFile } = window.GeoPackage;// Serve sql-wasm.wasm from your /public directory.setSqljsWasmLocateFile(file => '/public/' + file);
By default the library tries to load sql-wasm.wasm from the root of the current server. Copy the file from:
node_modules/rtree-sql.js/dist/sql-wasm.wasm
to your public directory (e.g. public/sql-wasm.wasm), then call setSqljsWasmLocateFile with the matching path prefix.
setSqljsWasmLocateFile must be called before the first GeoPackageManager.open call. If the browser cannot find the WASM file, the library will throw an error when it tries to open or create a GeoPackage.
You can run GeoPackage operations inside a Web Worker to keep the main thread responsive. Import the bundle with importScripts and configure sql.js the same way as in the main thread:
The following packages are listed as optionalDependencies. They are not required for core functionality and will not be installed unless your environment resolves optional deps.
Package
Purpose
better-sqlite3
Faster native SQLite adapter for Node.js (falls back to sql.js if absent)
chalk
Coloured output in the CLI tool
inquirer
Interactive prompts in the CLI tool
If you want maximum read/write performance in Node.js, install better-sqlite3 explicitly. It is a native addon and requires a C++ build toolchain: