vitorTheDev
BABetter Auth
•Created by vitorTheDev on 2/12/2025 in #bug-reports
bun: Couldn't read your auth config in auth.ts
Using bun (win11), it's impossible to get both
generate
and runtime to work using just whats in the docs.
The issue seems to be some problem with c12
package, that does'n return an object like {default}
, but instead return only the auth object itself.
If you only return export default auth;
it erros:
- runtime: SyntaxError: Export named 'auth' not found in module 'C:\dev\backend\src\lib\auth.ts'
- [#better-auth]: Couldn't read your auth config in C:\dev\backend\src\lib\auth.ts. Make sure to default export your auth instance or to export as a variable named auth.
(even with --config
param)
- it works if I export default { auth }
Not a big problem, but thought it would be good to report anyway.
If you only return export const auth = ...
it works both runtime and generation (but it was erroring before, also related to c12 but at runtime, maybe it was something wrong somewhere else in my code, but it's ok now)
my gess is that it was related to community plugin better-auth-harmony, which uses validator.js esm, because I had to fork and add "type": "module" to validator.js to make it work with "module": "NodeNext" tsconfig, but i'm just guessing).3 replies