I have a barebones NestJS app where all I have done is add a .env
file with PORT=3001
as the content and then modified my main.ts
according to the NestJS docs:
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {bufferLogs: true});
const configService = app.get(ConfigService);
const PORT = configService.get('PORT');
app.listen(PORT);
}
bootstrap();
My AppModule:
@Module({
imports: [
ConfigModule.forRoot({isGlobal: true}),
UsersModule
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
When I run the app, it always runs on port 3000. It never runs on port 3001. What is going on???