Skip to content

CLI failing to generate Drizzle schema with Postgres #4305

Description

@Cosina14

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

This is a vanilla setup

  1. npx create-next-app@latest
  2. npm install drizzle-orm
  3. npm install drizzle-kit --save-dev
  4. npm install @neondatabase/serverless
  5. npm install better-auth
  6. Setup .env in root and auth.ts in /lib (auth.ts is vanilla and based on https://www.better-auth.com/docs/installation)
  7. Setup Drizzle stuff vanilla as per https://orm.drizzle.team/docs/tutorials/drizzle-nextjs-neon
  8. sudo apt install build-essential
  9. npm install -g node-gyp
  10. npx --verbose @better-auth/cli generate

Step 10 will fail which led me to come up with Steps 8 and 9 but it didnt help

os= Linux 6.6.87.2-microsoft-standard-WSL2
node= v24.7.0
npm= v11.5.2

Seems to fail at =>

npm http cache semver@https://registry.npmjs.org/semver/-/semver-6.3.1.tgz 0ms (cache hit)
npm http cache dotenv@https://registry.npmjs.org/dotenv/-/dotenv-17.2.1.tgz 0ms (cache hit)
npm http cache semver@https://registry.npmjs.org/semver/-/semver-6.3.1.tgz 0ms (cache hit)
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 710ms
npm info run prisma@5.22.0 preinstall node_modules/prisma node scripts/preinstall-entry.js
npm info run prisma@5.22.0 preinstall { code: 0, signal: null }
npm info run better-sqlite3@11.10.0 install node_modules/better-sqlite3 prebuild-install || node-gyp rebuild --release
npm info run better-sqlite3@11.10.0 install { code: 1, signal: null }

Works with pnpm however. Go figure!
I also wonder why its trying to get things like better-sqlite3 when postgres is required or prisma when drizzle is being used.

Current vs. Expected behavior

Expect auth-schema.ts to generate but CLI is failing

What version of Better Auth are you using?

1.3.7

System info

OS: Linux 6.6 Ubuntu 25.04 25.04 (Plucky Puffin)
CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-1235U
Memory: 1.13 GB / 3.66 GB
Container: Yes
Shell: 5.2.37 - /bin/bash

node= v24.7.0
npm=  v11.5.2

Which area(s) are affected? (Select all that apply)

Other

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "@/db/drizzle";
 
export const auth = betterAuth({
    database: drizzleAdapter(db, {
        provider: "pg",
    }),
});

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglockedLocked conversations after being closed for 7 days

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions