porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.38k stars 267 forks source link

TypeError setting up client #877

Open paulrenenichols opened 4 months ago

paulrenenichols commented 4 months ago

Trying to use postgres with drizzle in a nestjs app. Getting this error when I run the server:

/Users/paulrenenichols/SoftDev/interviews/zello/admin-portal/services/server/src/database/db.ts:7 const client = postgres(dbUrl); ^ TypeError: (0 , postgres_1.default) is not a function at Object.<anonymous> (/Users/paulrenenichols/SoftDev/interviews/zello/admin-portal/services/server/src/database/db.ts:7:24) at Module._compile (node:internal/modules/cjs/loader:1358:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10) at Object.require$$0.Module._extensions..js (/Users/paulrenenichols/SoftDev/interviews/zello/admin-portal/.pnp.cjs:20941:33) at Module.load (node:internal/modules/cjs/loader:1208:32) at Function.Module._load (node:internal/modules/cjs/loader:1024:12) at Function.require$$0.Module._load (/Users/paulrenenichols/SoftDev/interviews/zello/admin-portal/.pnp.cjs:20789:31) at Module.require (node:internal/modules/cjs/loader:1233:19) at require (node:internal/modules/helpers:179:18) at Object.<anonymous> (/Users/paulrenenichols/SoftDev/interviews/zello/admin-portal/services/server/src/customer/customer.service.ts:2:1)

Here is the source code for that file:

import { drizzle } from 'drizzle-orm/postgres-js';
import * as schema from './schema';
import postgres from 'postgres';

const dbUrl = process.env.DATABASE_URL;

const client = postgres(dbUrl);
export const db = drizzle(client, { schema, logger: true });

I'm using Yarn 4 pnp to manage my packages.

kam-st commented 3 months ago

Type issues are coming from drizzle, please post this issue on drizzle repo.