PrismaP
Prisma3mo ago
4 replies
chiptus

ReferenceError: Cannot access 'pg' before initialization

Hi everyone,

I love prisma.
I use it with my react-router project, but I recently started to migrate to tanstack start. the project is a monorepo managed with pnpm and turborepo

prisma schema and types are in a shared library called "@myproj/db"

on the tanstack project, it works in development, but when I try to build and preview I see "ReferenceError: Cannot access 'pg' before initialization"

any idea what happens here?

the portion of code that throws the error is this:

const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  get Client() {
    return Client;
  },
  get Connection() {
    return Connection;
  },
  get DatabaseError() {
    return DatabaseError;
  },
  get Pool() {
    return Pool;
  },
  get Query() {
    return Query;
  },
  get Result() {
    return Result;
  },
  get TypeOverrides() {
    return TypeOverrides;
  },
  get default() {
    return pg; <------- this line
  },
  get defaults() {
    return defaults;
  },
  get escapeIdentifier() {
    return escapeIdentifier;
  },
  get escapeLiteral() {
    return escapeLiteral;
  },
  get types() {
    return types$1;
  }
}, Symbol.toStringTag, { value: "Module" }));
Was this page helpful?