Bug
When buildDir is not explicitly set in nuxt.config.ts and a .nuxt/ directory exists from dev, Nuxt Kit redirects buildDir to node_modules/.cache/nuxt/.nuxt during production builds (source).
The hub:db:schema:extend hook in nuxt-better-auth prefers the .ts path over .mjs:
// module.mjs:277-286
nuxtWithHubHooks.hook("hub:db:schema:extend", ({ paths, dialect: hookDialect }) => {
const tsPath = join(nuxt.options.buildDir, "better-auth", `schema.${hookDialect}.ts`);
const mjsPath = join(nuxt.options.buildDir, "better-auth", `schema.${hookDialect}.mjs`);
if (existsSync(tsPath)) {
paths.unshift(tsPath); // prefers .ts
return;
}
if (existsSync(mjsPath))
paths.unshift(mjsPath);
});
Since the .ts file ends up inside node_modules/, Node.js type stripping refuses to process it:
ERROR Stripping types is currently unsupported for files under node_modules,
for "node_modules/.cache/nuxt/.nuxt/better-auth/schema.sqlite.ts"
Fix
Prefer .mjs over .ts in the hook — the generated schema code is pure JS anyway, so .mjs works fine.
Workaround
Set buildDir: '.nuxt' explicitly in nuxt.config.ts to prevent the redirect.