[GH-ISSUE #8154] @better-auth/cli@latest generate does not work with deno #11006

Open
opened 2026-04-13 07:23:08 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @rmaclean on GitHub (Feb 25, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8154

Originally assigned to: @himself65 on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. deno init
  2. deno add --npm better-auth
  3. create your auth.ts
  4. try run dx @better-auth/cli@latest generate

Current vs. Expected behavior

Current

Should generate the schema but fails. The best I could get was to set nodeModulesDir in the deno.json to auto, but with this or not, it errors

[#better-auth]: Couldn't read your auth config. TypeError: Import "@better-auth/core/utils" not a dependency
  hint: If you want to use a JSR or npm package, try running `deno add jsr:@better-auth/core/utils` or `deno add npm:@better-auth/core/utils`
    at file:///Users/robert/workspace/facebook/api/node_modules/.deno/better-auth@1.4.18/node_modules/better-auth/dist/index.mjs:20:15
    at async import (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522)
    at async /Users/robert/workspace/facebook/api/lib/auth.ts:1:212
    at async Function.import (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522)
    at async resolveConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:320:20)
    at async loadConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:149:22)
    at async getConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/@better-auth+cli@1.4.18/node_modules/@better-auth/cli/dist/index.mjs:222:25)
    at async Command.generateAction (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/@better-auth+cli@1.4.18/node_modules/@better-auth/cli/dist/index.mjs:33:17) {
  code: "ERR_MODULE_NOT_FOUND"
}

Expected

It works

What version of Better Auth are you using?

1.4.18

System info

deno 2.6.10 (stable, release, aarch64-apple-darwin)
v8 14.5.201.2-rusty
typescript 5.9.2



{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:15 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6000",
    "release": "25.3.0",
    "cpuCount": 10,
    "cpuModel": "Apple M1 Pro",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.13 GB"
  },
  "node": {
    "version": "v25.6.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.9.0"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null,
    "error": "Deno is not defined"
  }
}

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

Client

Auth config (if applicable)

n/a - any auth config will have it happen

Additional context

No response

Originally created by @rmaclean on GitHub (Feb 25, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8154 Originally assigned to: @himself65 on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. deno init 2. deno add --npm better-auth 3. create your auth.ts 4. try run `dx @better-auth/cli@latest generate` ### Current vs. Expected behavior # Current Should generate the schema but fails. The best I could get was to set `nodeModulesDir` in the `deno.json` to `auto`, but with this or not, it errors ``` [#better-auth]: Couldn't read your auth config. TypeError: Import "@better-auth/core/utils" not a dependency hint: If you want to use a JSR or npm package, try running `deno add jsr:@better-auth/core/utils` or `deno add npm:@better-auth/core/utils` at file:///Users/robert/workspace/facebook/api/node_modules/.deno/better-auth@1.4.18/node_modules/better-auth/dist/index.mjs:20:15 at async import (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522) at async /Users/robert/workspace/facebook/api/lib/auth.ts:1:212 at async Function.import (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522) at async resolveConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:320:20) at async loadConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:149:22) at async getConfig (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/@better-auth+cli@1.4.18/node_modules/@better-auth/cli/dist/index.mjs:222:25) at async Command.generateAction (file:///Users/robert/Library/Caches/deno/deno_x_cache/npm-@better-auth__cli@latest/node_modules/.deno/@better-auth+cli@1.4.18/node_modules/@better-auth/cli/dist/index.mjs:33:17) { code: "ERR_MODULE_NOT_FOUND" } ``` # Expected It works ### What version of Better Auth are you using? 1.4.18 ### System info ```bash deno 2.6.10 (stable, release, aarch64-apple-darwin) v8 14.5.201.2-rusty typescript 5.9.2 { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:15 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6000", "release": "25.3.0", "cpuCount": 10, "cpuModel": "Apple M1 Pro", "totalMemory": "16.00 GB", "freeMemory": "0.13 GB" }, "node": { "version": "v25.6.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.9.0" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null, "error": "Deno is not defined" } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript n/a - any auth config will have it happen ``` ### Additional context _No response_
GiteaMirror added the platformdevtoolsbug labels 2026-04-13 07:23:08 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 25, 2026):

Hi @rmaclean! I'm Dosu and I’m helping the better-auth team.

This is a known limitation — the Better Auth CLI isn't compatible with Deno due to native Node.js dependencies (like better-sqlite3) and module resolution that doesn't work with Deno's compatibility layer.

Recommended workaround: Use Node.js temporarily to run the CLI:

  1. npm i better-auth better-sqlite3
  2. npx @better-auth/cli generate
  3. Clean up: rm -rfv package.json package-lock.json node_modules
  4. Use the generated schema in your Deno project

Also, CLI version 1.3.4 is more stable than newer versions which have some broken imports:

npx @better-auth/cli@1.3.4 generate

Recent work like the ESM migration and utils module refactoring are improving compatibility, but full Deno CLI support isn't available yet.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3961395454 --> @dosubot[bot] commented on GitHub (Feb 25, 2026): <!-- Greeting --> Hi @rmaclean! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known limitation — the Better Auth CLI [isn't compatible with Deno](https://github.com/better-auth/better-auth/issues/892) due to native Node.js dependencies (like `better-sqlite3`) and module resolution that doesn't work with Deno's compatibility layer. **Recommended workaround**: Use Node.js temporarily to run the CLI: 1. `npm i better-auth better-sqlite3` 2. `npx @better-auth/cli generate` 3. Clean up: `rm -rfv package.json package-lock.json node_modules` 4. Use the generated schema in your Deno project Also, [CLI version 1.3.4 is more stable](https://github.com/better-auth/better-auth/issues/3951#issuecomment-3179468385) than newer versions which have some broken imports: ``` npx @better-auth/cli@1.3.4 generate ``` Recent work like the [ESM migration](https://github.com/better-auth/better-auth/pull/5260) and [utils module refactoring](https://github.com/better-auth/better-auth/pull/7288) are improving compatibility, but full Deno CLI support isn't available yet. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3ff6673a-9b42-46c5-b545-8040d44c7971?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20limitation%20%E2%80%94%20the%20Better%20Auth%20CLI%20%5Bisn%27t%20compatible%20with%20Deno%5D%28https%3A//github.com/better-auth/better-auth/issues/892%29%20due%20to%20native%20Node.js%20dependencies%20%28like%20%60better-sqlite3%60%29%20and%20module%20resolution%20that%20doesn%27t%20work%20with%20Deno%27s%20compatibility%20layer.%0A%0A%2A%2ARecommended%20workaround%2A%2A%3A%20Use%20Node.js%20temporarily%20to%20run%20the%20CLI%3A%0A%0A1.%20%60npm%20i%20better-auth%20better-sqlite3%60%0A2.%20%60npx%20%40better-auth/cli%20generate%60%0A3.%20Clean%20up%3A%20%60rm%20-rfv%20package.json%20package-lock.json%20node_modules%60%0A4.%20Use%20the%20generated%20schema%20in%20your%20Deno%20project%0A%0AAlso%2C%20%5BCLI%20version%201.3.4%20is%20more%20stable%5D%28https%3A//github.com/better-auth/better-auth/issues/3951%23issuecomment-3179468385%29%20than%20newer%20versions%20which%20have%20some%20broken%20imports%3A%0A%60%60%60%0Anpx%20%40better-auth/cli%401.3.4%20generate%0A%60%60%60%0A%0ARecent%20work%20like%20the%20%5BESM%20migration%5D%28https%3A//github.com/better-auth/better-auth/pull/5260%29%20and%20%5Butils%20module%20refactoring%5D%28https%3A//github.com/better-auth/better-auth/pull/7288%29%20are%20improving%20compatibility%2C%20but%20full%20Deno%20CLI%20support%20isn%27t%20available%20yet.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/8154)
Author
Owner

@himself65 commented on GitHub (Mar 1, 2026):

dx auth generate
[#better-auth]: Couldn't read your auth config. TypeError: Import "better-auth/db" not a dependency
  hint: If you want to use the npm package, try running `deno add npm:better-auth/db`
    at file:///Users/himself65/Code/better-auth/packages/electron/dist/index.mjs:15:33
    at async import (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522)
    at async /Users/himself65/Code/better-auth/demo/nextjs/lib/auth.ts:1:210
    at async Function.import (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522)
    at async resolveConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:320:20)
    at async loadConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:149:22)
    at async getConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/auth@1.5.0/node_modules/auth/dist/index.mjs:224:25)
    at async Command.generateAction (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/auth@1.5.0/node_modules/auth/dist/index.mjs:94:17) {
  code: "ERR_MODULE_NOT_FOUND"
}
<!-- gh-comment-id:3979428474 --> @himself65 commented on GitHub (Mar 1, 2026): ``` dx auth generate [#better-auth]: Couldn't read your auth config. TypeError: Import "better-auth/db" not a dependency hint: If you want to use the npm package, try running `deno add npm:better-auth/db` at file:///Users/himself65/Code/better-auth/packages/electron/dist/index.mjs:15:33 at async import (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522) at async /Users/himself65/Code/better-auth/demo/nextjs/lib/auth.ts:1:210 at async Function.import (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158522) at async resolveConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:320:20) at async loadConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/c12@3.3.3/node_modules/c12/dist/index.mjs:149:22) at async getConfig (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/auth@1.5.0/node_modules/auth/dist/index.mjs:224:25) at async Command.generateAction (/Users/himself65/Library/Caches/deno/deno_x_cache/npm-auth/node_modules/.deno/auth@1.5.0/node_modules/auth/dist/index.mjs:94:17) { code: "ERR_MODULE_NOT_FOUND" } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#11006