nexus generate supabase url not found (env variable)

267 views Asked by At

Prisma Nexus generate does not find environment variable

I have import 'dotenv/config' at the root of my Apollo Server set. So I can develop fine. However, when I try to run ts-node --transpile-only apollo/schema I get the following error.

This tells me that dotenv isn't running on generate. Is there a configuration for this somewhere?

/{user-path}/node_modules/@supabase/supabase-js/src/SupabaseClient.ts:62
    if (!supabaseUrl) throw new Error('supabaseUrl is required.')
                            ^
Error: supabaseUrl is required.
    at new SupabaseClient (/{user-path}/node_modules/@supabase/supabase-js/src/SupabaseClient.ts:62:29)
    at createClient (/{user-path}/node_modules/@supabase/supabase-js/src/index.ts:21:10)
    at /{user-path}/apollo/src/supabase-client.ts:9:22
    at Object.<anonymous> (/{user-path}/apollo/src/supabase-client.ts:10:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/{user-path}/node_modules/ts-node/src/index.ts:1371:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/{user-path}/node_modules/ts-node/src/index.ts:1374:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
error Command failed with exit code 1.
1

There are 1 answers

0
axecopfire On

I put import 'dotenv/config' at the root of the apollo server so running the server was fine. However, when I go to build the schema directly I don't get my env vars. So I also put the dotenv/config in my schema.ts. It's not a great solution since on server startup I config twice. But it works for now. Would appreciate to hear a better solution if anyone has one.