New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NODE_ENV is undefined #251
Comments
Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/251 |
Hello guys, I'm also having this behavior using multi-env. I can only use multi-env if I set
api.cache.invalidate(() => process.env.NODE_ENV);
console.log('env', process.env.NODE_ENV);
console.log('benv', process.env.BABEL_ENV);
console.log('appenv', process.env.APP_ENV);
return {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module:react-native-dotenv',
{
moduleName: '@env',
path: '.env',
safe: false,
allowUndefined: true,
},
]...
"start:dev": "APP_ENV=development expo start -c",
"start:prod": "APP_ENV=production expo start -c" running production script the logs are: transform[stdout]: env undefined
transform[stdout]: benv development
transform[stdout]: appenv production the |
I figured out how to reproduce the error and I'm investigating |
@goatandsheep thank you for the quick answer. I'm building with |
I figured out how to fix @karlvr 's problem. @tgwow |
@tgwow look into creating a dev build https://docs.expo.dev/development/getting-started/ |
im having a similar strange behavior using expo 44 and "react-native-dotenv": "^3.3.1" console.log(process.env);
/*
output:
Object {
"NODE_ENV": "development",
}
*/
console.log(process.env.NODE_ENV);
/*
output:
undefined
*/ |
This fixes goatandsheep#251 (comment) react-native sets the `NODE_ENV` **after** this transformation happens. Code that directly access `process.env.NODE_ENV` was replaced by `babelMode` during transformation (if latest babel was used) or by `undefined`. With this commit, any access to a `process.env` variable is only replaced by the corresponding value if its value is set.
This fixes goatandsheep#251 (comment) react-native sets the `NODE_ENV` **after** this transformation happens. Code that directly access `process.env.NODE_ENV` was replaced by `babelMode` during transformation (if latest babel was used) or by `undefined`. With this commit, any access to a `process.env` variable is only replaced by the corresponding value if its value is set.
This fixes goatandsheep#251 (comment) react-native sets the `NODE_ENV` **after** this transformation happens. Code that directly access `process.env.NODE_ENV` was replaced by `babelMode` during transformation (if latest babel was used) or by `undefined`. With this commit, any access to a `process.env` variable is only replaced by the corresponding value if its value is set.
RN 0.68.1/react-native-dotenv 3.3.1: If the output of "process.env.NODE_ENV" is undefined, don't set NODE_ENV on "process.env.NODE_ENV", set it on the const value:
|
@douglascavanaugh thanks, really helped. But why this trick with |
Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/251 |
This fixes #251 (comment) react-native sets the `NODE_ENV` **after** this transformation happens. Code that directly access `process.env.NODE_ENV` was replaced by `babelMode` during transformation (if latest babel was used) or by `undefined`. With this commit, any access to a `process.env` variable is only replaced by the corresponding value if its value is set.
Describe the bug
After upgrading from 3.2.0 to 3.3.0 my use of
process.env.NODE_ENV
returnsundefined
. It seems that 3.3.0 added support forprocess.env
, but maybe clobbersNODE_ENV
? I tried added to theblocklist
, and I havesafe
set totrue
, but nothing seemed to change the behaviour except downgrading to 3.2.0.To Reproduce
Steps to reproduce the behavior:
console.log(process.env.NODE_ENV)
undefined
instead ofdevelopment
orproduction
Expected behavior
The
process.env.NODE_ENV
should be untouched.The text was updated successfully, but these errors were encountered: