Skip to content

Commit e10df18

Browse files
committed
fix(db): resolve @nuxthub/db from rootDir for pnpm
1 parent ea6305c commit e10df18

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/devtools.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { existsSync } from 'node:fs'
2+
import { resolve } from 'node:path'
3+
import { pathToFileURL } from 'node:url'
14
import { logger } from '@nuxt/kit'
25
import type { Nuxt } from 'nuxt/schema'
36
import type { HubConfig, ResolvedDatabaseConfig } from '@nuxthub/core'
@@ -20,7 +23,11 @@ async function launchDrizzleStudio(nuxt: Nuxt, hub: HubConfig) {
2023

2124
try {
2225
const { dialect, driver, connection } = dbConfig
23-
const { schema } = await import(nuxt.options.alias!['hub:db'] as string)
26+
const dbEntry = resolve(nuxt.options.rootDir, 'node_modules', '@nuxthub', 'db', 'db.mjs')
27+
if (!existsSync(dbEntry)) {
28+
throw new Error(`Cannot find @nuxthub/db at ${dbEntry}. Run \`nuxi prepare\` to generate it.`)
29+
}
30+
const { schema } = await import(pathToFileURL(dbEntry).href)
2431

2532
// Launch Drizzle Studio based on dialect and driver
2633
if (dialect === 'postgresql') {

0 commit comments

Comments
 (0)