简体   繁体   中英

node-config returns always default settings

I'm moving a node.js/express application to nest.js. The config of the app is handled with node-config ( default.js and host specific js-files). I have copied the config files to the new application folder, imported the config module, and used some config.get() calls. The old application works perfect but with nest.js I get only the settings from default.js. Does anybody know why node-config is not working with nest.js?

// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as config from "config";

async function bootstrap() {
    const port = Number.parseInt( config.get( "application.port" ), 10 );
    console.log( `Server listening on port: ${port}` );

    const app = await NestFactory.create( AppModule );
    await app.listen( port );
}
bootstrap();

config.get() returns always the value from default.js

Found the problem, there must be some changes between versions 2 and 3 of the config module that made the filename loading algorithm case sensitive. Going back to v2 solved the problem. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM