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–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
dbinfo
✓ const dbinfo = require('db-info');
✗ import dbinfo from 'db-info';
This package is CommonJS-only and does not support ES modules. Attempting to import with `import` syntax will result in a runtime error in ES module contexts.
getInfo
✓ const dbinfo = require('db-info');
dbinfo.getInfo(...);
✗ import { getInfo } from 'db-info';
The primary functionality `getInfo` is accessed as a method on the default CommonJS export. Destructuring is not supported.
Demonstrates how to initialize `db-info` with an existing SQLite database connection to retrieve its table and column metadata.
const sqlite3 = require('sqlite3').verbose();
const dbinfo = require('db-info');
// Create an in-memory SQLite database for demonstration
const db = new sqlite3.Database(':memory:', (err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQLite database.');
// Create a dummy table
db.run(`CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE,
age INTEGER
)`, (err) => {
if (err) {
// Table might already exist if run multiple times in same process
if (err.message.includes('already exists')) {
console.log('Table "users" already exists, proceeding.');
} else {
return console.error('Error creating table:', err.message);
}
} else {
console.log('Table "users" created successfully.');
}
// Get database metadata using db-info
dbinfo.getInfo({
driver: 'sqlite3',
db: db
}, function(err, result) {
if (err) {
return console.error('Error getting DB info:', err.message);
}
console.log('Database metadata retrieved:');
console.log(JSON.stringify(result, null, 2));
// Close the database connection
db.close((err) => {
if (err) {
return console.error(err.message);
}
console.log('Closed the database connection.');
});
});
});
});
Debug
Known issues
breakingThe package is abandoned and has not been updated since 2012. It requires Node.js >=0.6.0 and is highly unlikely to be compatible with modern Node.js versions (e.g., Node.js 16+), modern database drivers, or contemporary security practices.fixConsider using modern alternatives like ORMs (e.g., Prisma, TypeORM, Sequelize) or database query builders that are actively maintained and support current Node.js and database versions.
affects: All versions (0.0.3)
gotchaThis package is CommonJS-only (`require`). It cannot be directly `import`ed in an ES module project without explicit transpilation or wrapper functions, which might introduce further compatibility issues due to its age.fixEnsure your project is configured for CommonJS or use a dynamic `import()` statement if absolutely necessary, but migration to a modern library is strongly recommended.
affects: All versions (0.0.3)
deprecatedThe underlying database drivers it supports (e.g., `node-sqlite3`, `node-mysql`, `node-postgres`, `node-oracle`) have evolved significantly since 2012. Using this package likely means relying on very old, potentially insecure, and unmaintained versions of these drivers.fixManually manage and configure modern database drivers and use their native introspection capabilities, or use a contemporary ORM/query builder.
affects: All versions (0.0.3)
gotchaThe API is exclusively callback-based, which is an outdated pattern in modern JavaScript/Node.js. It does not support Promises or async/await natively, leading to callback hell if integrating with modern asynchronous code.fixIf forced to use, wrap `getInfo` in a Promise-returning function using `util.promisify` (if compatible) or a manual Promise constructor, but anticipate other compatibility issues.
affects: All versions (0.0.3)
gotchaThe package lists `async` as a dependency which likely refers to a very old version of the `async` library. This old version might have its own compatibility issues or even known vulnerabilities.fixAudit `npm ls` for transitive dependencies and their versions. The primary fix is to avoid this abandoned package entirely.
affects: All versions (0.0.3)
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require` in an ES module environment (e.g., in a file with `"type": "module"` in `package.json` or a `.mjs` file).
fixThis package is CommonJS-only. Either configure your project for CommonJS (`"type": "commonjs"` in `package.json` or use `.cjs` extensions) or find a modern, actively maintained alternative. Dynamic `import()` might technically work but is not recommended for an abandoned package.
Error: Cannot find module 'sqlite3'
A required database driver (e.g., `sqlite3`, `mysql`, `pg`, `db-oracle`) is not installed or available in the project's `node_modules`.
fixInstall the specific driver needed using npm: `npm install sqlite3` (or `mysql`, `pg`, `db-oracle`). Note that older versions of these drivers might be required for compatibility with `db-info` itself.
Error: Callback was already called.
A common issue in callback-based APIs where the callback function provided to `getInfo` is invoked multiple times, often due to error handling logic not returning early after an error.
fixReview the code invoking `dbinfo.getInfo` to ensure the callback is only called once per execution path. This often requires careful `if (err) return callback(err);` patterns.
Error: connect ECONNREFUSED
The target database server (e.g., MySQL, PostgreSQL, Oracle) is not running, is configured incorrectly, or network access is blocked by a firewall.
fixVerify the database server is running and accessible from the machine executing the Node.js application. Check connection parameters (host, port, user, password, database) for correctness and ensure no firewall rules are blocking the connection.
Audit
Dependencies
asyncrequiredUtility for managing asynchronous operations, a direct runtime dependency mentioned in installation instructions.
sqlite3optionalRequired for SQLite database driver, if 'sqlite3' is specified as the driver option.
mysqloptionalRequired for MySQL database driver, if 'mysql' is specified as the driver option.
pgoptionalRequired for PostgreSQL database driver, if 'pg' is specified as the driver option. (Listed on npm registry page).
db-oracleoptionalRequired for Oracle database driver, if 'db-oracle' is specified as the driver option. (Listed on npm registry page).