Put in order · NestJS course · Module 1: NestJS Basics

Environment Configuration in NestJS

Arrange the steps for configuring environment variables from first to last:

Items to put in order

  • Using configService.get('KEY') in services
  • Creating the .env file with keys and values
  • Registering ConfigModule.forRoot() in the root module
  • Injecting ConfigService through the constructor
Show the answer

Correct order:

  1. Creating the .env file with keys and values
  2. Registering ConfigModule.forRoot() in the root module
  3. Injecting ConfigService through the constructor
  4. Using configService.get('KEY') in services