knex+workers TypeError

I was working with Cloudflare Workers + bun & Hono and was using Knex as my orm. I was successfully ably to make a connection on Cloudlfare Pages to Knex+Postgres with Connection Pooling however on Workers I am recieving a TypeErorr.

I tried using both the connectionString and specifiying the individual parameters for the database. Additionally I set node_compat = true
and also added the
node:
prefix previously when using compatibility_flags = ["nodejs_compat"]

I also played around with the version numbers of both the sql connection adapter
pg
and
knex


Error:
[wrangler:err] TypeError: this.driver.Client is not a constructor
    at Client_PG._acquireOnlyConnection (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/dialects/postgres/index.js:81:24)
    at Client_PG.acquireRawConnection (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/dialects/postgres/index.js:99:17)
    at create (file:///home/sanner/Coding/Anemo/auth.ran.so/node_modules/knex/lib/client.js:262:39)


Error Source:
knex({
  client: 'pg',  // Replace 'pg' with your database client if different
  connection: {
    host: "hostDB",
    port: 5432,
    user: "postgres",
    password: "passwordDB",
    database: "databaseName",
    ssl: {
      rejectUnauthorized: false,
    },
  },
  searchPath: ['knex', 'public'],  // Optional: Specify search path for PostgreSQL
});
Was this page helpful?