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" }));
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" }));
3 Replies
Prisma AI Help
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Nurul
Nurul3w ago
It is difficult to predict what might be going wrong before seeing the setup. Are you using the latest prisma version?
chiptus
chiptusOP3w ago
Yes. Latest prisma version 6.19.0
before seeing the setup.
what setup do you need to see?

Did you find this page helpful?