question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

process.env does not expose its keys as expected

See original GitHub issue

I’m not sure if this is expected, but it doesn’t feel right.

If I run an app with

$ REACT_APP_FOO=bar npm start

I can access process.env.REACT_APP_FOO, but REACT_APP_FOO in process.env returns false, and process.env["REACT_APP_FOO"] is undefined.

I’m trying to have something like:

function getConfig(key) {
   if (key in process.env) {
     return process.env[key];
   }

   return defaults[key];
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
fsoncommented, Oct 12, 2016

This is going to be included in 0.7.0, which will be out soon.

1reaction
gaearoncommented, Sep 30, 2016

Fixed in #807.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my custom process.env not working within dotenv?
it works. So my error was a scope issue. No need to set const keys so just using require('./config/env') I can access any...
Read more >
Using Environment Variables in Node.js for App Configuration ...
env is always true (even once the key has been deleted), you're not alone. It's because it will only return false if the...
Read more >
Basic Features: Environment Variables - Next.js
By default environment variables are only available in the Node.js environment, meaning they won't be exposed to the browser. ... This loads process.env....
Read more >
Environment variables in Compose | Docker Documentation
Your configuration options can contain environment variables. Compose uses the variable values from the shell environment in which docker-compose is run.
Read more >
Environment Variable visible in browser - Netlify Support Forums
Thank you, did look at it, I am setting the environment variable via the UI during build and deployment, my code is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found