Skip to content

Error: Could not resolve #auth/schema #292

@hareland

Description

@hareland

Description

It is not possible to import the generated schema from #auth/schema -> this breaks when you attempt to run npx nuxt db generate

Error:

npx nuxt db generate
ℹ Ensuring database schema is generated...                                                        2:27:01 PM
Error: Build failed with 1 error:

[RESOLVE_ERROR] Error: Could not resolve '#auth/schema' in server/db/schema.ts
   ╭─[ server/db/schema.ts:2:24 ]
   │
 2 │ import { schema } from '#auth/schema'
   │                        ───────┬──────  
   │                               ╰──────── Matched alias not found for '#auth/schema'
   │ 
   │ Help 1: May be you expected `resolve.alias` to call other plugins resolveId hook? see the docs https://rolldown.rs/apis/config-options#resolve-alias for more details
   │ 
   │ Help 2: 'server/db/schema.ts' is imported by the following path:
   │           - server/db/schema.ts
   │           - .nuxt/hub/db/schema.entry.ts
───╯

    at aggregateBindingErrorsIntoJsError (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/rolldown@1.0.0-beta.57/node_modules/rolldown/dist/shared/bindingify-input-options-B8B4dvr-.mjs:61:18)
    at unwrapBindingResult (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/rolldown@1.0.0-beta.57/node_modules/rolldown/dist/shared/bindingify-input-options-B8B4dvr-.mjs:31:128)
    at #build (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/rolldown@1.0.0-beta.57/node_modules/rolldown/dist/shared/rolldown-build--qygLwCL.mjs:2269:34)
    at async build (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/rolldown@1.0.0-beta.57/node_modules/rolldown/dist/index.mjs:28:22)
    at async Promise.all (index 0)
    at async buildSingle (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/tsdown@0.18.4_typescript@5.9.3_vue-tsc@3.2.5_typescript@5.9.3_/node_modules/tsdown/dist/src-DrqLE2Pt.mjs:995:19)
    at async Promise.all (index 0)
    at async build$1 (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/tsdown@0.18.4_typescript@5.9.3_vue-tsc@3.2.5_typescript@5.9.3_/node_modules/tsdown/dist/src-DrqLE2Pt.mjs:944:18)
    at async buildDatabaseSchema (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/@nuxthub+core@0.10.7_db0@0.3.4_@electric-sql+pglite@0.3.15_@libsql+client@0.17.2_drizzl_0a4fb5f79dad428fd3b489c9beb8f3f3/node_modules/@nuxthub/core/dist/db/lib/build.mjs:65:3)
    at async Object.run (file:///Users/<readacted>/Workspace/personal/<readacted>/nuxt-app-name/node_modules/.pnpm/@nuxthub+core@0.10.7_db0@0.3.4_@electric-sql+pglite@0.3.15_@libsql+client@0.17.2_drizzl_0a4fb5f79dad428fd3b489c9beb8f3f3/node_modules/@nuxthub/core/cli/commands/db/generate.mjs:51:5) {
  errors: [Getter/Setter]
} 

server/db/schema.ts

import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'
import { schema } from '#auth/schema'

export const dashboards = sqliteTable('dashboards', {
  id: text('id').primaryKey(),
  name: text('name').notNull(),
  description: text('description'),
  createdAt: integer('created_at', { mode: 'timestamp' }).$defaultFn(() => new Date()),
  updatedAt: integer('updated_at', { mode: 'timestamp' }).$onUpdateFn(() => new Date()),
})

export const usersDashboards = sqliteTable('users_dashboards', {
  userId: text('user_id').references(() => schema.user.id),
  dashboardId: text('dashboard_id').references(() => dashboards.id),
  role: text('role', { enum: ['owner', 'admin', 'user'] }).default('user'),
  createdAt: integer('created_at', { mode: 'timestamp' }).$defaultFn(() => new Date()),
  updatedAt: integer('updated_at', { mode: 'timestamp' }).$onUpdateFn(() => new Date()),
})

npx nuxt info:

Operating system macOS 25.3.0
CPU Apple M1 Pro (8 cores)
Node.js version v24.6.0
nuxt/cli version 3.34.0
Package manager pnpm@10.32.1
Nuxt version 4.4.2
Nitro version 2.13.1
Builder vite@7.3.1
Config auth, compatibilityDate, content, css, devtools, eslint, hub, modules, routeRules, vite
Modules @nuxt/eslint@1.15.2, @nuxthub/core@0.10.7, @nuxt/ui@4.5.1, @nuxt/content@3.12.0, @nuxt/image@2.0.0, @nuxt/scripts@0.13.2, @nuxt/test-utils@4.0.0, @nuxtjs/i18n@10.2.3, @nuxtjs/seo@4.0.2, @onmax/nuxt-better-auth@0.0.2-alpha.31

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions