#.env values not being loaded up in environment?
15 messages · Page 1 of 1 (latest)
You'd have to share how you're loading that file, to begin with
tbh I thought it just automatically works
it appears to be the case on the other projects I copied things over from
nop
nor nestjs nor nodejs load them automatically
and there are couple ways to do so
try nest start --env-file .env
(assuming that you're using nestjs v11)
There are some libraries that load .env without you knowing it. Prisma is one of them.
I am using prisma on all of the other ones indeed
--env-file .env doesn't seem to do the trick 😦
will try dotenv, should be plenty of ways to load it
was just super-confused as to why it's not working for this particular project as i haven't touched anything, but it seems to be prisma loading it in all the other ones
I just tested this here and everything worked as expected, so I don't know 🤔
The --env-file is node.js feature introduced in node 20: https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs.
Not sure whether nest cli passes the flag down to node, I believe there was a way to do that.