Drizzle + Sveltekit + Cloudflare + Supabase cannot get to work.

If I use Drizzle's docs, like :
import { Pool } from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
I get node module resolution errors like:
node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
node_modules/pg/lib/connection.js:3:18: ERROR: Could not resolve "net"
node_modules/pg/lib/connection-parameters.js:3:18: ERROR: Could not resolve "dns"
node_modules/pg/lib/connection.js:3:18: ERROR: Could not resolve "net"
If I follow Supabase's docs on connecting with drizzle, like:
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
I get node module errors like:
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
Cloudflare definitely says to use the newer colon-delimited name like node:stream, and I have followed all of Cloudflare's instructions for node compatibility, but these errors persist. Anyone have advice?
S
sizzF161d ago
Add the option node_compat = true to wrangler.toml.
B
Brucey131d ago
Did you try postgres-js instead of node-postgres for the drizzle import? Worked for me
B
boggin131d ago
I tried adding in node_compat=true flag in the dashboard (I dont have a wrnagler file with Sveltekit) I'm not sure if I tried postgres-js (OP was too long ago to remember) I gave up and just started using Supabase's sdk which is certianly enough of an ORM, I was looking to keep the ORM flavor with drizzle. I will try this just for funsies though
MO
Mike Oristian46d ago
having the same problem - tried with both postgres-js and pg library