title: Env Variables in NestJS not visible in every module?
body: <p>Im keeping my configuration in <code>.env</code> file when I develop my app.</p>
  
  <p>This is my <code>app.module.ts</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>@Module({
    imports: [
      ConfigModule.forRoot({ isGlobal: true }),
      TypeOrmModule.forRoot({
        autoLoadEntities: true,
        database: process.env.TYPEORM_DATABASE,
        host: process.env.TYPEORM_HOST,
        password: process.env.TYPEORM_PASSWORD,
        port: (process.env.TYPEORM_PORT as unknown) as number,
        type: 'postgres',
        username: process.env.TYPEORM_USERNAME,
      }),
      AuthModule,
      (...)
    ],
    controllers: [],
    providers: [],
  })
  export class AppModule {}
  </code></pre>
  
  <p>And <code>typeorm</code> use proper values from <code>process.env.TYPEORM_...</code> variables.</p>
  
  <p>This is my <code>auth.module.ts</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>@Module({
    providers: [JwtStrategy, (...)],
    imports: [
      JwtModule.register({
        secret: process.env.JWT_SECRET,
        (...)
      }),
      (...)
    ],
    controllers: [AuthController],
  })
  export class AuthModule {}
  </code></pre>
  
  <p>And Im getting error from JwtModule, that <code>secret</code> can not be empty. Of course <code>JWT_SECRET</code> is set in <code>.env</code> file.</p>
  
  <p>This is my <code>jwt.strategy.ts</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>@Injectable()
  export class JwtStrategy extends PassportStrategy(Strategy) {
    constructor() {
      super({
        secretOrKey: process.env.JWT_SECRET,
        (...)
      });
    }
    (...)
  }
  </code></pre>
  
  <p>And here, <code>process.env.JWT_SECRET</code> is properly loaded.</p>
  
  <p>I cant understand why my env vars are not available everywhere in my app.</p>