-
Notifications
You must be signed in to change notification settings - Fork 19
Description
steps to reproduce:
- make new nuxt project
bunx nuxi init - add prisma nuxt
bun i @prisma/nuxtand addmodules: ["@prisma/nuxt"]to nuxt.config.ts - run client
bun devand approve prisma migrations & the like - add the following to
app.vue, and hoverclient
<script lang="ts" setup>
const client = usePrismaClient()
</script>it shows loading... for 30s to 3 minutes, then says any
this doesnt make sense because if you ctrl click usePrismaClient after it shows () => any for its type definition, it gives you
const usePrismaClient: typeof import('../../node_modules/@prisma/nuxt/dist/runtime/composables/usePrismaClient')['usePrismaClient']
and if you follow that with ctrl click, you get
export declare const usePrismaClient: () => import(".prisma/client").PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>;
which if you hover, have a meaningful type signature () => import(".prisma/client").PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>
and all the components of that type signature have reasonable definitions too
so why is the type signature of usePrismaClient () => any?
as further debugging steps I tried:
- importing
usePrismaClientmanually - using npm instead of bun
- disabling all my extensions except for the offical nuxtr extension pack
- copy pasting
./.nuxt/tsconfig.jsonin its entirety to./tsconfig.json, I replaced all instances of ./ with ./.nuxt/ and replaced all instances of .. with ., to fix relative pathing following moving the file - ran it on another machine
usePrismaClientis still() => any
I tried testing if it worked on server routes, so I made
server/api/test.ts
export default defineEventHandler(async (event) => {
return await prisma.user.findMany()
})prisma is supposed to be auto imported here and it isnt!
If I try importing prisma manually, it says @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again. which is #97