I wanted to implement the ConfigService of Nestjs v8.1.1
I've place the .env file in the project's root (not src folder) and the file has this content:
HOST=http://localhost
PORT=8088
The app.Module.ts is enriched with the import:
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
cache: true,
envFilePath: '.env',
}),
...]
I've tried without the options and with these listed options.
When it is trying to get the value of the variable, it results in
var address = this.configService.get('HOST', 'http://localhost')
^
TypeError: Cannot read properties of undefined (reading 'get')
FYI the code is run in an extended class, which should not make a difference.
export default class KsqldbSignalsClient extends ClientProxy {
constructor(private configService: ConfigService) {
super()
}
async connect(): Promise<any> {
var address = this.configService.get('HOST', 'http://localhost')
...
Any hint (even confirmation that it works for you) is appreciated.