admin管理员组

文章数量:1244331

I've installed Supabase locally on my dev machine (and plan to deploy it to a non-Supabase host). So far, everything with Supabase itself has worked great (e.g. I can navigate to http://127.0.0.1:54323/ to see the "Studio").

However, whenever I try to generate types for my client, I get a confusing error:

$ npx supabase gen types typescript 

Access token not provided. Supply an access token by running supabase login or setting the SUPABASE_ACCESS_TOKEN environment variable.

I don't have an access token, and since I'm self-hosted I can't get one. I don't understand why I'd even need one just to generate types (that has nothing to do with my choice of hosts).

Does anyone know how I can generate types locally?

I thought perhaps the environmental variables from my .env.local weren't being accessed, so I tried adding them at the command line:

$ SUPABASE_URL=http://127.0.0.1:54321 SUPABASE_KEY=1234_MY_SECRET_KEY_5678 npx supabase gen types typescript 

However, I still got the same error.

I've installed Supabase locally on my dev machine (and plan to deploy it to a non-Supabase host). So far, everything with Supabase itself has worked great (e.g. I can navigate to http://127.0.0.1:54323/ to see the "Studio").

However, whenever I try to generate types for my client, I get a confusing error:

$ npx supabase gen types typescript 

Access token not provided. Supply an access token by running supabase login or setting the SUPABASE_ACCESS_TOKEN environment variable.

I don't have an access token, and since I'm self-hosted I can't get one. I don't understand why I'd even need one just to generate types (that has nothing to do with my choice of hosts).

Does anyone know how I can generate types locally?

I thought perhaps the environmental variables from my .env.local weren't being accessed, so I tried adding them at the command line:

$ SUPABASE_URL=http://127.0.0.1:54321 SUPABASE_KEY=1234_MY_SECRET_KEY_5678 npx supabase gen types typescript 

However, I still got the same error.

Share Improve this question edited 2 days ago machineghost asked Feb 17 at 19:05 machineghostmachineghost 35.8k32 gold badges173 silver badges259 bronze badges 1
  • The documentation states: npx supabase gen types typescript --local > database.types.ts – first last Commented Feb 18 at 8:58
Add a comment  | 

1 Answer 1

Reset to default 2

If you have the CLi installed you can run with the --local flag as indicated in the comment from first last

npx supabase gen types --local

But if you are self-hosting and want to generate it based on the hosted elsewhere, then you can also pass the DB-URL: --db-url flag.

Note that you can also generate types for Swift and Typescript:

--lang <[ typescript | swift ]>

All details are available on the docs

本文标签: How do I generate types with Supabase locally (ie not hosted with Supabase)Stack Overflow