Heroku Node.js Cannot find Environment Variables

I have defined 2 environment variables in heroku. Running heroku config shows:

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

However when I run my node.js app and run console.log(process.env) I get:

{ NODE_ENV: 'production' }

Versions: node - 8.9.1, npm - default

The code is written in ES6 and built using webpack. The build is successful.

Please let me know if you need any more information.

1 answer

  • answered 2018-03-11 12:57 Yoni Rabinovitch

    Where do you get those results? When running your node.js app locally or on Heroku? If locally, you need to set your env vars in your local environment.
    Alternatively, if you just want to use your Heroku env vars in your local environment, you can use heroku-run-localjs.