【问题标题】:Why am I getting "Configuration property is not defined"?为什么我收到“未定义配置属性”?
【发布时间】:2021-01-18 23:46:35
【问题描述】:

当我运行我的index.js 文件时,我得到了Configuration property "mail.host" is not defined。我不明白为什么。

config.get('name') 工作正常。我设置了我的NODE_ENV=production。有人可以帮忙吗?

index.js

const config = require('config');
console.log(config.get('name'));
console.log(config.get('mail.host'));

production.json

{
  "name": "My app - production",
  "mail": {
    "host": "production-server"
  }
}

【问题讨论】:

  • production.json 应该在一个名为config的文件夹中

标签: node.js npm config


【解决方案1】:

重启终端后就可以使用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-30
    • 2017-09-16
    • 2020-06-12
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    相关资源
    最近更新 更多