【问题标题】:How to make node.js automatically load config files如何让 node.js 自动加载配置文件
【发布时间】:2016-04-15 21:01:04
【问题描述】:

在 node.js 中,你可以使用 'require()' 加载您的配置文件,但我厌倦了必须在我的所有程序上这样做。有没有办法让 node.js 自动加载配置文件?

【问题讨论】:

  • 显式总是比隐式好。不要偷懒。

标签: node.js shell command-line config configuration-files


【解决方案1】:

没关系。我发现你可以通过将它放在你的 '.bash_profile' 或 unix 机器上的 shell 配置文件中来做到这一点:

alias node='node -r ./config.js'

【讨论】:

    猜你喜欢
    • 2015-05-04
    • 2021-05-14
    • 2020-08-02
    • 1970-01-01
    • 1970-01-01
    • 2010-10-05
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多