Skip to content

fix(oss): make pgvector pg import compatible with ESM#4544

Merged
whysosaket merged 1 commit intomem0ai:mainfrom
fmercurio:fix/pg-esm-import
Mar 26, 2026
Merged

fix(oss): make pgvector pg import compatible with ESM#4544
whysosaket merged 1 commit intomem0ai:mainfrom
fmercurio:fix/pg-esm-import

Conversation

@fmercurio
Copy link
Copy Markdown
Contributor

@fmercurio fmercurio commented Mar 25, 2026

Fix: pgvector pg import compatibility with Node ESM

Problem

In the OSS bundle, the pgvector vector store imports pg like this:

import { Client } from "pg";

But pg is a CommonJS module. Under Node ESM, it does not provide named exports, so module evaluation fails with:

SyntaxError: Named export 'Client' not found. The requested module 'pg' is a CommonJS module

This breaks downstream integrations (e.g. OpenClaw Mem0 plugin) because the OSS bundle throws during import, causing memory capture and recall to fail.

Solution

Switch to a CJS-safe ESM import style:

import type { Client as ClientType } from "pg";
import pkg from "pg";
const { Client } = pkg;

private client: ClientType;

Testing

  • Node: v22.22.0
  • pnpm test in mem0-ts/

Closes: #4543

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@fmercurio
Copy link
Copy Markdown
Contributor Author

I force-pushed a new commit with corrected author/committer (Felippe Mercurio fmercurio@gmail.com) so the CLA bot should be able to match the signer.

@utkarsh240799
Copy link
Copy Markdown
Contributor

Hi @fmercurio ,

Thank you for your taking the the time to come up with the fix. Can you please sign the CLA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mem0ai OSS: pgvector import breaks under Node ESM (Named export 'Client' not found)

5 participants