#How to use .env.local in ConfigModule env path or multiple different .env files

1 messages · Page 1 of 1 (latest)

subtle pasture
#

Hi guys, hope youre doing great!
Im trying to work on setting up different .env files like .env.local, .env.development etc to split my env variables,
How do i reference this file in my config module?

Im a bit stumped since nestjs** configModule by default looks for .env file** and not .env.<some-extension>

sterile garden
#
ConfigModule.forRoot({
  envFilePath: ['.env.development.local', '.env.development'],
});```
subtle pasture
#

Hey thanks, does the file path need to be absolute or relative or just the filename? How does it know where to look for the file? Does order of file import matter here?

supple orbit
#

https://docs.nestjs.com/techniques/configuration#custom-env-file-path

By default, the package looks for a .env file in the root directory of the application
So I think it's root-relative

sterile garden
#

shortly ConfigModule uses dotenv.