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

Configuration Source Priority

The application registers ConfigModule.forRoot({ envFilePath: ['.env.production', '.env'] }). Arrange the sources of a value for the same key from highest to lowest priority:

Items to put in order

  • Values from .env.production (the first file in envFilePath)
  • The default value in configService.get('KEY', defaultValue)
  • Values from the .env file
  • Operating system environment variables
Show the answer

Correct order:

  1. Operating system environment variables
  2. Values from .env.production (the first file in envFilePath)
  3. Values from the .env file
  4. The default value in configService.get('KEY', defaultValue)