PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] How can I tell react-native what .env file to look at?

 August 19, 2022     android, environment, environment-variables, javascript, react-native     No comments   

Issue

On windows, I'm developing a white label app and trying to use env variables to make code specific builds. I'm using react-native-config and I followed their setup on GitHub, but for some reason SET ENVFILE=.env.myenvironment doesn't do anything for me, even with a defined map in build-gradle like this:

project.ext.envConfigFiles = [
debug: ".env",
release: ".env",
anothercustombuild: ".env.custombuild",
]

Any ideas?


Solution

I was using vscode integrated terminal to pass the react-native-config command to tell RN which .env file to look at, and it wasnt working at all..

I started using powershell for windows and tryed the correct command for it. And it work wonders. e.g. $env:ENVFILE=".env.mycustomenvironment"; react-native run-android. It should work the same for react-native run-ios as well as for release builds.

Keep in mind that as of right now (08/20/2019), react-native-config isnt working properly with product flavors in RN 0.60+ when it comes to exposing the .env vars to your .JS files, if you are looking for a workaround for that, take a look at this post but tl;dr is to use react-native-config with react-native-build-config.



Answered By - LuizfBrisighello
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing