Just realizing today you cant used ENV's from `.en...
# help
r
Just realizing today you cant used ENV's from
.env
files before a Stack class, they only seem to exist at constructor time. is this expected? seems odd even if I add
import 'dotenv/config'
myself to my
index.ts
or the stack
t
that's strange
I don't even know how that's possible
r
yeah right 🤷‍♂️ seems super odd. but
console.log(process.env)
before export default class is different then in the constructor
oh strange the errors are with the debug stack
Its almost like the debug stack is loading my file, but doesnt call the constructor?
and in that situation the ENVs dont exist... which usually would be fine but i added in throwing errors when they are missing.
So it looks like Envs are not available for the debug stack, so i am not able to validate them prior to the constructor.
@thdxr alright so it looks like this error is coming from
.build/lib/index.js
I am not sure how this gets generated but i dont see anything in here to load the
.env.stage
or
env.local
file anywhere. My process.env checks within my stacks are surfaced to the very top. So when they are missing the errors throw. Think I will need to rework how i do this here.
t
I'm kind of confused - why is the debug stack relevant?
.env is loaded by the CLI and passed to most processes the cli spawns
r
I dont know why the debug stack is relevant also haha but if i require a ENV outside of my class it is not there in the debug stack. Like it seems like the debug stack is loading my stack files but not constructing them? but also the debug stack does have access to my .envs. So for example
if (!<http://process.env.MY|process.env.MY>_SECRET) throw new Error('Needed that')
always seems to be an issue.
t
That's odd debug stack shouldn't know anything about your code, it's a static set of things that are deployed
hm
r
Maybe its not the debug stack, just where the errors pop up, maybe something early on is loading all my stacks before envs. They become available by the time my constructor is called. So something must be telling dotenv to load up certain .env files, seems like that is happening after the stack file are loaded.