[1.5.0] @better-auth/cli not matching the latest version error
✅Solved
1. What the issue? The cli doesn't work on the latest version of better-auth. (better-auth v1.5.0) 2. Error message:
$ bunx @better-auth/cli@latest generate --output ../db/src/schema/auth.ts --config ./src/index.ts --yesfile:///C:/Users/maged/AppData/Local/Temp/bunx-3619830099-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/generators-Ht8QYIi_.mjs:4import { getAuthTables, getMigrations } from "better-auth/db"; ^^^^^^^^^^^^^SyntaxError: The requested module 'better-auth/db' does not provide an export named 'getMigrations' at #asyncInstantiate (node:internal/modules/esm/module_job:302:21) at async ModuleJob.run (node:internal/modules/esm/module_job:405:5) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)Node.js v24.13.0error: script "db:auth-generate" exited with code 1
$ bunx @better-auth/cli@latest generate --output ../db/src/schema/auth.ts --config ./src/index.ts --yesfile:///C:/Users/maged/AppData/Local/Temp/bunx-3619830099-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/generators-Ht8QYIi_.mjs:4import { getAuthTables, getMigrations } from "better-auth/db"; ^^^^^^^^^^^^^SyntaxError: The requested module 'better-auth/db' does not provide an export named 'getMigrations' at #asyncInstantiate (node:internal/modules/esm/module_job:302:21) at async ModuleJob.run (node:internal/modules/esm/module_job:405:5) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)Node.js v24.13.0error: script "db:auth-generate" exited with code 1
3. How to reproduce? Just install better-auth (v 1.5.0) and use the cli
bunx @better-auth/cli@latest generate
bunx @better-auth/cli@latest generate
to get this error. 4. How to fix it: This fixes the issue