Closed magnusrodseth closed 1 year ago
Kysely doesn't require you to install any drivers. There are zero internal dependencies to external libraries. The dialects take all their dependencies as arguments when you instantiate them.
The PostgresDialect
doesn't use the native module in any way. It uses the Pool
you give it and nothing else.
The dependency requirements might come from kysely-codegen
or some third party dialect you might be using, but definitely not from kysely.
Another guess is that when you install pg
some bundler you use incorrectly thinks you also need to install pg-native
. In this case I'd search this from pg
repo's issues.
If you create your Kysely
instance without pg
for example like this:
import {
DummyDriver,
Kysely,
PostgresDialect,
PostgresAdapter,
PostgresCompiler,
PostgresIntrospector,
PostgresQueryCompiler,
} from 'kysely'
const db = new Kysely<DB>({
dialect: {
createAdapter: () => new PostgresAdapter(),
createDriver: () => new DummyDriver(),
createIntrospector: (db) => new PostgresIntrospector(db),
createQueryCompiler: () => new PostgresQueryCompiler(),
},
})
and remove all references to the pg
module, you should see the error go away. Not that this is a solution, but it should assure you that Kysely is not the culprit here.
I use a Turborepo, where I have an apps/web
which is my Next app and a packages/timeseries
package, which is my connection and library for interacting with the timeseries Postgres database. I fixed this by deleting the timeseries
package, and using kysely
in apps/web
in getServerSideProps
.
Suboptimal and a bit messy, but it works.
I'm struggling with
pg
andpg-native
. Mypackage.json
looks like this:Note that this package is part of a monorepo, including a Next.js application that consumes this package to interface with the PostgreSQL database.
I need to have both
pg
andpg-native
for my application to build and run. The same goes for my GitHub Actions workflow and Vercel preview deployment - they won't attempt to run without thepg-native
dependency installed.Locally, everything now runs, and I get to extract sensible data from my TimescaleDB PostgreSQL database. I get data
console.log
-ed in my browser that actually stems from the database.My GitHub CI workflow build correctly, so there's no problem with the
pg-native
dependency there. However, my Vercel preview deployment gets the following error withpg-native
installed:Googling this error, I read this thread and they immediately started talking about
pg-native
.I don't understand why I should even need
pg-native
when usingkysely
with thepg
package. Is there some reason this won't run serverless - is that it?