drizzle-team/drizzle-orm

[BUG]: Missing Dependency Error: `pg` required for new database client Initialization API

Closed this issue · 1 comments

What version of drizzle-orm are you using?

0.35.3

What version of drizzle-kit are you using?

0.26.2

Describe the Bug

After migrating to the new Database initialization API in v0.35.3, I encounter the following error:

error: Cannot find package "pg" from "/myproject/node_modules/.pnpm/drizzle-orm@0.35.3_@libsql+client-wasm@0.14.0_@types+pg@8.11.10_@types+react@18.3.4_postgres@3.4.5_react@18.3.1/node_modules/drizzle-orm/node-postgres/driver.js"

Minimum Reproducible Example

package.json

{
  "dependencies": {
    "drizzle-orm": "^0.35.3"
  }
}

main.ts

import { drizzle } from "drizzle-orm/node-postgres";

const db = drizzle("MY HARDCODED DATABASE URL");

Steps Taken to Resolve

  1. Switched from pnpm to npm.
  2. Ran main.ts with Deno.
  3. Ran main.ts with Bun.
  4. Noticed an error suggesting to install @types/pg; added @types/pg to the dependencies.
  5. Added node-postgres to the dependencies.
  6. Added postgres to the dependencies.

Solution

The issue was resolved by adding pg to the dependencies. Here’s the updated package.json:

{
  "name": "example",
  "dependencies": {
    "drizzle-orm": "^0.35.3",
    "pg": "^8.13.1"
  }
}

Expected behavior

The client should initialize without errors, or, if the database client requires specific dependencies, the documentation should explicitly mention these requirements.

Environment & setup

  • pnpm 9.7.1
  • npm 10.8.2
  • bun 1.1.21
  • deno 2.0.0

MacBook Pro M2 Pro
macOS Sequoia 15.0.1

I'm sorry but didn't this already mentioned in the document for PostgreSQL?

Document URL: Step 1 - Install packages

Below is the code from that step for NPM:

npm i drizzle-orm pg
npm i -D drizzle-kit @types/pg

You claim this:

if the database client requires specific dependencies, the documentation should explicitly mention these requirements.

But the document did contain the pg package in the "Install packages" as I mentioned above. So I have no idea what are you talking about!