Registry / database / sqlite-regex

sqlite-regex

JSON →
library0.2.4-alpha.1jsnpmunverified

sqlite-regex is a SQLite extension that adds fast regular expression functions, distributed via npm as a pre-compiled native addon for Node.js. Version 0.2.4-alpha.1 is current; release cadence is irregular as it's maintained by a single developer. Key differentiator: it wraps the RE2 library for safe and performant regex operations, avoiding ReDoS vulnerabilities, and works as a drop-in extension for better-sqlite3 and node-sqlite3. Only supports macOS (x64/arm64), Windows x64, and Linux x64; other platforms may need manual compilation. ESM-only package.

npm install sqlite-regex
INSTALL
IMPORT
SIG · SQLITE-REGEX
S
sqlite-regex
databasejavascriptv0.2.4-alpha.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getLoadablePath
import { getLoadablePath } from 'sqlite-regex'
const { getLoadablePath } = require('sqlite-regex')
The package is ESM-only (no default export), so CommonJS require() will fail. Use dynamic import() if needed.
sqlite_regex
import * as sqlite_regex from 'sqlite-regex'
import sqlite_regex from 'sqlite-regex'
There is no default export; the namespace import is correct to access getLoadablePath.
getLoadablePath
import { getLoadablePath } from 'sqlite-regex'
const path = require('sqlite-regex').getLoadablePath
CommonJS require() is not supported; you must use ESM imports.

Demonstrates loading the sqlite-regex extension into better-sqlite3, then using regex_match and regex_captures functions in SQL queries.

import Database from 'better-sqlite3'; import { getLoadablePath } from 'sqlite-regex'; const db = new Database(':memory:'); db.loadExtension(getLoadablePath()); // Use regex functions in SQL queries const result = db.prepare( "SELECT regex_match('hello', '^h.*o') AS matched" ).get(); console.log(result); // { matched: 1 } // Example with capture groups const rows = db.prepare( "SELECT regex_captures('abc123', '([a-z]+)(\\d+)') AS captures" ).get(); console.log(rows.captures); // { 0: 'abc123', 1: 'abc', 2: '123' }
Debug
Known issues
breakingPackage is ESM-only; require() will throw ERR_REQUIRE_ESM.
fix
Use import statements or dynamic import() instead of require().
affects: >=0.2.0
gotchagetLoadablePath() returns the path to the platform-specific prebuilt extension; if the platform isn't supported (e.g., Linux ARM), the path won't exist and loadExtension will fail.
fix
Check supported platforms: darwin-x64, darwin-arm64, win32-x64, linux-x64. For unsupported platforms, compile the extension from source.
affects: *
gotchaThe package uses optional dependencies to download platform-specific binaries. If npm install fails to fetch the correct optional dependency (e.g., due to network or registry issues), the extension will be missing.
fix
Manually install the appropriate platform-specific package (e.g., sqlite-regex-darwin-x64) or set npm config to ignore optional dependencies and build from source.
affects: *
deprecatedThe sqlite-regex extension uses RE2 for safety but may not support all PCRE features (e.g., backreferences, lookahead).
fix
Review RE2 syntax limitations; use alternative LIKE or GLOB for simple patterns if needed.
affects: *
gotchaBinding to node-sqlite3: db.loadExtension() is asynchronous and expects a callback; calling it synchronously will cause a TypeError.
fix
Use the callback pattern: db.loadExtension(getLoadablePath(), (err) => { if (err) console.error(err); });
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'sqlite-regex'
The package is ESM-only and cannot be required with CommonJS require().
fix
Use import { getLoadablePath } from 'sqlite-regex' instead of require('sqlite-regex').
TypeError: db.loadExtension is not a function
Attempt to call loadExtension on a database object that doesn't have that method (e.g., using raw sqlite3 without extension loading).
fix
Ensure you are using better-sqlite3 or node-sqlite3, which have loadExtension. For node-sqlite3, ensure you've created a Database instance.
Error: The specified module could not be found.
getLoadablePath() returned a path to a binary that doesn't exist because the platform is unsupported.
fix
Check process.arch and process.platform; only x64 and arm64 for macOS, Windows, Linux are supported. For other platforms, build from source.
Error: dlopen(.../sqlite-regex.node): image not found
The .node binary is missing because optional dependency wasn't installed (npm install failed or was skipped).
fix
Delete node_modules and reinstall with npm install --ignore-scripts=false (ensure scripts run). Or manually install the platform-specific package.
Upgrade
Version history
0.2.4-alpha.1latest on npm
Audit
Dependencies
better-sqlite3optionalCommon SQLite client that can load extensions; not required but is the recommended client.
node-sqlite3optionalAlternative SQLite client that can load extensions; not required
Agent activity
15 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources