supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Nuxt3 api/me route cannot resolve import from '#supabase/server'

Open ASoldo opened this issue 1 year ago • 2 comments

Hi, I'm having typescript error saying that cannot find module in "#supabase/server" even tho everything works fine, it's just that error. Tried in VS Code, Nvim and got same error. For now i use // @ts-ignore for that part but it's just so I can find fix for it. Anybody know how to fix this? problem

Version

@nuxtjs/supabase: v0.3.7 nuxt: v3.5.3

Steps to reproduce

Create server/api/me.ts and try to import serverSupabaseUser without typescript error

What is Expected?

Typescript should be able to import and show types for serverSupabaseUser when importing.

What is actually happening?

Typescript is throwing error that it cannot find module or declaration in #supabase/server as shown in image above.

ASoldo avatar Jun 12 '23 22:06 ASoldo

@ASoldo I'm getting the same thing. I think it's something to do with how VSCode is resolving the generated types in .nuxt/types/supabase.d.ts as the typescript compiler doesn't seem to have an issues with it.

My hack is a little more tolerable than @ts-ignore. I simply copied the type defs to server/types.d.ts. Unfortunately I wasn't able to find the root issue in the time I have.

declare module "#supabase/server" {
  const serverSupabaseClient: typeof import("../node_modules/@nuxtjs/supabase/dist/runtime/server/services").serverSupabaseClient;
  const serverSupabaseServiceRole: typeof import("../node_modules/@nuxtjs/supabase/dist/runtime/server/services").serverSupabaseServiceRole;
  const serverSupabaseUser: typeof import("../node_modules/@nuxtjs/supabase/dist/runtime/server/services").serverSupabaseUser;
}

richardvanbergen avatar Jun 21 '23 03:06 richardvanbergen

I also get the same issue. Any idea to solve this issue?

MSufianS avatar Jun 24 '23 09:06 MSufianS