I am stuck for several days with duckDB nodeJS binding from NPM. I am simply trying a database creation with:
import * as duckdb from 'duckdb'
const db = new duckdb.Database(':memory:');
but this triggers the following error:
const db = new duckdb.Database(':memory:');
^
TypeError: duckdb.Database is not a constructor
at file:///home/juju/workspace/gridtiler/npm/bin/gridtiler.js:64:12
at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
at async DefaultModuleLoader.import (node:internal/modules/esm/loader:228:24)
at async loadESM (node:internal/process/esm_loader:40:7)
at async handleMainPromise (node:internal/modules/run_main:66:12)
Node.js v20.4.0
while Database class is loaded. The execution does not recognize it as a class, apparently.
Is there something I missed?
A console.log(duckdb) returns:
[Module: null prototype] {
default: {
Database: [Function: Database],
Connection: [Function: Connection],
Statement: [Function: Statement],
QueryResult: [Function: QueryResult],
ERROR: -1,
OPEN_READONLY: 1,
OPEN_READWRITE: 0,
OPEN_CREATE: 0,
OPEN_FULLMUTEX: 0,
OPEN_SHAREDCACHE: 0,
OPEN_PRIVATECACHE: 0
}
}
which shows that Database class should be available...