jaredwray / keyv

Simple key-value storage with support for multiple backends
https://keyv.org
MIT License
2.61k stars 143 forks source link

@keyv/postgres doesn't work with ESM #1137

Closed meotimdihia closed 1 month ago

meotimdihia commented 1 month ago

Describe the bug import { Pool } from "pg"; ^^^^ SyntaxError: The requested module 'pg' does not provide an export named 'Pool' at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21) at async ModuleJob.run (node:internal/modules/esm/module_job:217:5) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

How To Reproduce (best to provide workable code or tests!)

import Keyv from "keyv"
import KeyvPostgres from "@keyv/postgres"

const keyv = new Keyv(new KeyvPostgres(process.env.DATABASE_URL))
export default keyv

This problem was told in this issue: https://github.com/brianc/node-postgres/issues/3060#issuecomment-1748047884 We could fix it in this file: https://github.com/jaredwray/keyv/blob/main/packages/postgres/src/pool.ts#L1

jaredwray commented 1 month ago

@meotimdihia - thanks for the info on this. I am looking at this now and will test to see if there is an easy fix on this.

jaredwray commented 1 month ago

PR Request is in and should be published in the next hour with the change: #1138

jaredwray commented 1 month ago

@meotimdihia - version 2.0.3 is now live. Hope that works.

meotimdihia commented 1 month ago

thanks, it works now :)