简体   繁体   中英

Why am I getting “Configuration property is not defined”?

When I run my index.js file, I am getting Configuration property "mail.host" is not defined . I don't understand why.

config.get('name') works fine. I set my NODE_ENV=production . Can anyone please help?

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"
  }
}

It works after restarting my Terminal.

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