Hao
Hao

Reputation: 6589

Nestjs is not getting dotenv value from ConfigModule

envFilePath setting for configuration in Nestjs is not working for me. Even I remove .env from it. .env is still loaded, not .evn.development.

Is it because I am using ConfigService? There is no mentioning about any contradiction.

import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';

@Module({
    imports: [
        ConfigModule.forRoot({
            envFilePath: ['.env.development', '.env'],
        });
    ]
})
export class AppModule {}

Upvotes: 0

Views: 208

Answers (1)

Hao
Hao

Reputation: 6589

Turned out it's myself.

I have a Strategy where I have some code there causing this issue.

import { config } from 'dotenv';

config();

Upvotes: 1

Related Questions