簡體   English   中英

node-config 始終返回默認設置

[英]node-config returns always default settings

我正在將 node.js/express 應用程序移動到 nest.js。 應用程序的配置由 node-config( default.js和主機特定的 js 文件)處理。 我已將配置文件復制到新的應用程序文件夾,導入配置模塊,並使用了一些config.get()調用。 舊應用程序運行良好,但使用 nest.js 我只能從 default.js 獲得設置。 有人知道為什么 node-config 不能與 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() 總是從 default.js 返回值

發現問題,配置模塊的2和3版本之間肯定有一些變化,使得文件名加載算法區分大小寫。 回到 v2 解決了這個問題。 :-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM