【发布时间】:2021-01-17 07:13:40
【问题描述】:
Error Screenshot[ 我正在使用 Node.js 并且已经设置了环境变量 vidly_jwtPrivateKey。并尝试使用此命令 config.get('vidly_jwtPrivateKey') 使用配置包检索它,但我不断收到此错误:
throw new Error('配置属性“'+属性+'”不是 定义');错误:配置属性“vidly_jwtPrivateKey”不是 定义,
我一直在寻找几个小时,请你提出一个解决方案。
这是我的 default.json 文件包含的内容:
{
"jwtPrivateKey" : ""
}
和 custom-environment-variables.json 包含:
{
"jwtPrivateKey" : "vidly_jwtPrivateKey"
}
我已经通过在终端中导出它来设置 vidly_jwtPrivateKey(我使用的是 Mac):
export vidly_jwtPrivateKey=mySecureKey.
这个我试过了,还是不行:
这是我用来检索环境变量的代码:
if (!config.get('vidly_jwtPrivateKey')){
console.error('FATAL ERROR : jwtPrivateKey is not defined '),
process.exit(1);
};
非常感谢
【问题讨论】:
标签: node.js express environment-variables config