Knex.js is a batteries-included SQL query builder for Node.js supporting PostgreSQL, MySQL, CockroachDB, MSSQL, SQLite3, and Oracle. The current stable version is 3.2.10, released with a monthly cadence. Key differentiators include a unified API across dialects, transaction support, connection pooling, streaming queries, and a comprehensive schema builder. TypeScript types are shipped. Requires Node.js >=16. Optional peer dependency pg-query-stream for PostgreSQL streaming.
npm install knexNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Knex instance connecting to PostgreSQL, creates a table, inserts a row, and queries it.
Use require('knex') for CommonJS or import knex from 'knex' for ESM.Update Node.js to >=16.
Migrate to a supported dialect or use a dedicated Oracle client.
Use import knex from 'knex' (not import { knex } from 'knex').Run: npm install pg
Ensure all queries complete before destroying, or use db.destroy() after Promise.all.
Use import knex from 'knex' (or const knex = require('knex')) and call knex(config).