You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error after upgrading to 0.18.1 : process.env.NODE_ENV undefined #5523
[warn][tid:com.facebook.React.JavaScript] undefined is not an object (evaluating 'process.env.NODE_ENV')
[error][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'process.env.NODE_ENV')
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!
My guess is it's one of the dependencies. We initialize process.env.NODE_ENV in InitializeJavaScriptAppEngine.js. Is it possible you're importing one of the dependencies before calling require('react-native')? I've seen this caused issues with Firebase.
Apologies I was trying to get some help on reactiflux but didn't get a reply, that's why I created an issue here. Next time I'll do it on stackoverflow :) Let me know if you'd rather have me close this issue and go to Stackoverflow, no problem!
In my code require('react-native') is always first and everything was working fine in 0.14.
This is the error that I am getting in Chrome and that's about it. It's flooding the logs. Thanks again for your help, and let me know if you'd like me to try something else.
It's strange it's working in a brand new app.. Can you try deleting node_modules and running npm install again?
Are you running the app from Xcode? The issue could be that Xcode has its own command-line environment so it's not picking up the NODE_ENV you've defined.
You could try starting the app using the new command react-native run-ios from your app's folder.
@mkonicek Thanks for your reply. If I delete node_modules and run npm install I get the following warnings:
npm WARN deprecated react-tools@0.13.2: react-tools is deprecated. For more information, visit https://fb.me/react-tools-deprecated
npm WARN engine stacktrace-parser@0.1.1: wanted: {"node":"~0.10"} (current: {"node":"5.3.0","npm":"3.3.12"})
npm WARN prefer global react-tools@0.13.2 should be installed with -g
npm WARN prefer global babel@5.8.35 should be installed with -g
npm WARN EPEERINVALID react-native-navbar@1.1.7 requires a peer of react-native@>= 0.16 but none was installed.
npm WARN EPEERINVALID react-native-material-kit@0.2.5 requires a peer of react-native@>=0.16.0 <1.0.0 but none was installed.
And the following naming collision error when running my app from Xcode:
Error building DependencyGraph:
Error: Naming collision detected:
node_modules/react-native-navigation-drawer/node_modules/react-native/packager/react-packager/src/DependencyResolver/haste/polyfills/String.prototype.es6.js
collides with
node_modules/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js
at HasteMap._updateHasteMap (HasteMap.js:132:13)
at HasteMap.js:103:28
at tryCallOne (node_modules/promise/lib/core.js:37:12)
at node_modules/promise/lib/core.js:123:15
at flush (node_modules/asap/raw.js:50:29)
at nextTickCallbackWith0Args (node.js:433:9)
at process._tickCallback (node.js:362:13)
If I try again after removing that module I'm getting back to the same error process.env.NODE_ENV undefined.
If install 0.19.0-rc to be able to run react-native run-ios I run into the exact same issues (naming collision then process.env.NODE_ENV undefined after removing the module).
I know you probably have better things to do, but I'd be really happy to hear about your suggestions if you have any. Otherwise I can try to create a brand new project and copy my JS files over, but that'd be rather painful).
@mkonicek I'm starting from a brand new project and reimporting all my code, seems like it might end up working. I'm closing this issue and I want to thank you again for your help; React Native is a fantastic tool and I look forward to keep using it.
@Taakn and anyone else who happens to stumble upon this. It looks like you may have based your app on https://github.com/spencercarli/meteor-todos-react-native as an example? If so I just found an issue related to 0.18 (in my example, not RN). I was defining process in the app but it seems that RN now adds process already... thus when we overwrote it env.NODE_ENV no longer exists.
Activity
facebook-github-bot commentedon Jan 24, 2016
Hey Taakn, thanks for reporting this issue!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
react-nativeor for more real time interactions, ask on Discord in the #react-native channel.mkonicek commentedon Jan 24, 2016
Can you try creating a brand new app? This way you'll know if the issue is related to your setup or one of the dependencies you're using.
Taakn commentedon Jan 24, 2016
@mkonicek Thanks for your suggestion. The brand new app is working fine... What do you think could be the root of the problem?
mkonicek commentedon Jan 24, 2016
My guess is it's one of the dependencies. We initialize
process.env.NODE_ENVinInitializeJavaScriptAppEngine.js. Is it possible you're importing one of the dependencies before callingrequire('react-native')? I've seen this caused issues with Firebase.mkonicek commentedon Jan 24, 2016
Meta: We should be discussing this on Stack Overflow before filing a bug :)
mkonicek commentedon Jan 24, 2016
In short, please make sure you always
require('react-native')as the very first thing.mkonicek commentedon Jan 24, 2016
Also, I'm surprised the stack trace only contains
index.ios.bundle. After waiting a while, do you see the real stack trace? Do you see it in logs?Taakn commentedon Jan 25, 2016
Apologies I was trying to get some help on reactiflux but didn't get a reply, that's why I created an issue here. Next time I'll do it on stackoverflow :) Let me know if you'd rather have me close this issue and go to Stackoverflow, no problem!
In my code require('react-native') is always first and everything was working fine in 0.14.
This is the error that I am getting in Chrome and that's about it. It's flooding the logs. Thanks again for your help, and let me know if you'd like me to try something else.
mkonicek commentedon Jan 25, 2016
It's strange it's working in a brand new app.. Can you try deleting
node_modulesand runningnpm installagain?Are you running the app from Xcode? The issue could be that Xcode has its own command-line environment so it's not picking up the
NODE_ENVyou've defined.You could try starting the app using the new command
react-native run-iosfrom your app's folder.Taakn commentedon Jan 25, 2016
@mkonicek Thanks for your reply. If I delete
node_modulesand runnpm installI get the following warnings:And the following naming collision error when running my app from Xcode:
If I try again after removing that module I'm getting back to the same error
process.env.NODE_ENV undefined.If install 0.19.0-rc to be able to run
react-native run-iosI run into the exact same issues (naming collisionthenprocess.env.NODE_ENV undefinedafter removing the module).I know you probably have better things to do, but I'd be really happy to hear about your suggestions if you have any. Otherwise I can try to create a brand new project and copy my JS files over, but that'd be rather painful).
Thanks again
Taakn commentedon Jan 25, 2016
@mkonicek I'm starting from a brand new project and reimporting all my code, seems like it might end up working. I'm closing this issue and I want to thank you again for your help; React Native is a fantastic tool and I look forward to keep using it.
spencercarli commentedon Feb 5, 2016
@Taakn and anyone else who happens to stumble upon this. It looks like you may have based your app on https://github.com/spencercarli/meteor-todos-react-native as an example? If so I just found an issue related to 0.18 (in my example, not RN). I was defining
processin the app but it seems that RN now adds process already... thus when we overwrote itenv.NODE_ENVno longer exists.Here's how I made that example app work with > 0.18 of RN https://github.com/spencercarli/meteor-todos-react-native/blob/master/ReactNativeTodos/app/config/db/lib/process.polyfill.js
Taakn commentedon Feb 8, 2016
@spencercarli Yes that's correct. I ended up using a similar fix.