I just had the same problem. For me the fix was in the main.ts
file. I needed to put the dotenv
configuration before all the imports of the files that use process.env
.
import * as dotenv from 'dotenv';
dotenv.config();
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
async function bootstrap() {
...