© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
12 replies
sevenwestonroads

Using Drizzle as a package in Turborepo doesn't work ?

I have a monorepo (Turborepo) with a shared package called @mono/database in which I put my drizzle schema and my types.

I'm testing a query on an app of this monorepo (a simple Node.js folder with TS files), and I also run the exact same query (with the same exact drizzle client definition) from my package to test it out. The thing is: the query works perfectly when ran from my package but outputs an error when run from my app that uses the content of the package.

When I run the query from my package directly, the logger it outputs the beautiful SQL statement complete with all the tables and fields.

But when I run it from my app (the Node.js folder with TS files) I get the following weird statement;
Query: select  from $1 left join $2 on $3 = $4 order by $5 desc limit $6 -- params: [[object Object], [object Object], [object Object], [object Object], [object Object], 1]
Query: select  from $1 left join $2 on $3 = $4 order by $5 desc limit $6 -- params: [[object Object], [object Object], [object Object], [object Object], [object Object], 1]

Which returns me the error below
.../.pnpm/pg@8.10.0/node_modules/pg/lib/utils.js:81
  return JSON.stringify(val)
              ^
TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'PgTable'
    |     property 'id' -> object with constructor 'PgSerial'
    --- property 'table' closes the circle
    at JSON.stringify (<anonymous>)
.../.pnpm/pg@8.10.0/node_modules/pg/lib/utils.js:81
  return JSON.stringify(val)
              ^
TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'PgTable'
    |     property 'id' -> object with constructor 'PgSerial'
    --- property 'table' closes the circle
    at JSON.stringify (<anonymous>)

------------------------------------------------
I logged the
client
client
in both cases, and also the
tables
tables
which outputted, for both, the exact object of 750 lines.

But when I copy / pasted the corresponding
pgTable
pgTable
directly in the file of my app in which I was importing my tables from the package and it works with no errors.

Here is the
package.json
package.json
of my
@mono/database
@mono/database
package.
{
  "name": "@mono/database",
  "version": "0.1.0",
  "main": "./index.ts",
  ...
 }
{
  "name": "@mono/database",
  "version": "0.1.0",
  "main": "./index.ts",
  ...
 }


Any idea ? So that means the bundling in the turborepo process might be creating the error ?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Can't get Drizzle working in turborepo as package
Drizzle TeamDTDrizzle Team / help
11mo ago
Query in drizzle doesn't work
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle in Turborepo
Drizzle TeamDTDrizzle Team / help
10mo ago
Schema in drizzle(pool, {schema}) doesn't work
Drizzle TeamDTDrizzle Team / help
3y ago