process.env does not expose its keys as expected
See original GitHub issueI’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:
- Created 7 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is going to be included in 0.7.0, which will be out soon.
Fixed in #807.