【问题标题】:Heroku Node.js Cannot find Environment VariablesHeroku Node.js 找不到环境变量
【发布时间】:2018-08-19 14:05:45
【问题描述】:

我在 heroku 中定义了 2 个环境变量。运行 heroku config 显示:

=== handandfootserver Config Vars PASSWORD: xxxxxxxxxxx PORT: 3001

但是,当我运行我的 node.js 应用程序并运行 console.log(process.env) 时,我得到:

{ NODE_ENV: 'production' }

版本:节点 - 8.9.1,npm - 默认

代码用 ES6 编写并使用 webpack 构建。构建成功。

如果您需要更多信息,请告诉我。

【问题讨论】:

    标签: node.js heroku environment-variables


    【解决方案1】:

    你从哪里得到这些结果?在本地或 Heroku 上运行 node.js 应用程序时?如果在本地,则需要在本地环境中设置环境变量。
    或者,如果您只想在本地环境中使用 Heroku 环境变量,您可以使用 heroku-run-localjs

    【讨论】:

    • 我在 Heroku 上运行时得到了这些结果。当我在本地运行时一切正常。
    猜你喜欢
    • 2020-08-23
    • 1970-01-01
    • 2012-09-24
    • 2016-07-11
    • 2013-04-17
    • 2015-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多