Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
parse
✓ import { parse } from 'sqlite3-parser'
✗ const parse = require('sqlite3-parser').parse
ESM-only since v0.7.0; CommonJS require is not supported. Use dynamic import or bundler with ESM interop.
parseStmt
✓ import { parseStmt } from 'sqlite3-parser'
✗ const { parseStmt } = require('sqlite3-parser')
Same ESM-only constraint. TypeScript users must ensure moduleResolution is 'node16' or 'bundler'.
parseOrThrow
✓ import { parseOrThrow } from 'sqlite3-parser'
Convenience function that throws on parse error. Useful when you know the SQL is valid.
type ParseOk
✓ import type { ParseOk } from 'sqlite3-parser'
✗ import { ParseOk } from 'sqlite3-parser'
ParseOk is a type-only export. Use `import type` to avoid runtime errors in isolated modules.
type ParseDiagnostic
✓ import type { ParseDiagnostic } from 'sqlite3-parser'
Error diagnostics are not subclasses of Error. Always check `result.status` before accessing error info.
Demonstrates parsing multiple statements, single statement, throwing on error, and incremental parsing with allowTrailing option.
import { parse, parseStmt, parseOrThrow } from 'sqlite3-parser';
// Parse multiple statements
const multi = parse(`SELECT * FROM t1; INSERT INTO t2 VALUES (1)`);
if (multi.status === 'ok') {
console.log(multi.root.cmds.length); // 2
console.log(multi.root.cmds[0].type); // SelectStmt
}
// Parse single statement
const single = parseStmt('SELECT id FROM users WHERE name = ?');
if (single.status === 'ok') {
console.log(single.root.type); // SelectStmt
}
// Parse or throw
const stmt = parseOrThrow('UPDATE t SET x = 1');
console.log(stmt.root.type); // CmdList (always contains one command)
// Incremental parsing with allowTrailing
const result = parseStmt('SELECT 1; SELECT 2', { allowTrailing: true });
if (result.status === 'ok') {
console.log(result.tail); // 9 (index where next statement starts)
}
Errors
Common errors & fixes
ERR_REQUIRE_ESM: Must use import to load ES Module: /node_modules/sqlite3-parser/index.js require() of ES modules is not supported.
Trying to require() the package which is ESM-only since v0.7.0.
fixReplace require('sqlite3-parser') with import { parse } from 'sqlite3-parser'. TypeError: result.ast is undefined
Accessing result.ast in code written for pre-0.6.0 API.
fixUse result.root instead of result.ast, and check result.status === 'ok' first.
ParseError: unexpected token at position X
Input SQL contains syntax errors or unsupported SQLite features.
fixCheck error message and location. Use parseStmt with allowTrailing to isolate problematic statements.
Audit
Dependencies
No dependency data recorded yet.