【发布时间】:2021-11-26 16:02:08
【问题描述】:
我正在尝试将我的 Web 应用程序(MERN 堆栈)推送到 Heroku,但我不断收到此错误
我尝试过的 在 index.js 中
if (!config.get("jwtPrivateKey")) {
throw new Error('FATAL ERROR!!: jwtPrivateKey is not defined')
}
console.log(config.get("DB"))
console.log(config.get("jwtPrivateKey"))
这是我记录它们时的价值
在 config 文件夹中有两个文件 default.json 和 custom-environment-variables.json 默认.json
{
"jwtPrivateKey" : "",
"requiresAuth": false,
"DB":"mongodb+srv://****/test"
}
自定义环境变量.json
{
"jwtPrivateKey" : "RhinoJohn_jwtPrivateKey",
"DB": "Rhinojohn_DB"
}
当我运行 heroku config 时,这里是变量 enter image description here
我检查了this 问题,但没有一个答案能解决我的问题。 如何解决未定义配置属性“jwtPrivateKey”?我没办法了
【问题讨论】:
-
“config”的导入语句是什么?
标签: javascript node.js heroku config web-deployment