Skip to content
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

Setting the right environment for development and release builds #209

Closed
snab88 opened this issue Jul 27, 2021 · 8 comments
Closed

Setting the right environment for development and release builds #209

snab88 opened this issue Jul 27, 2021 · 8 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@snab88
Copy link

snab88 commented Jul 27, 2021

I am trying to use .env.development and .env.production based off of NODE_ENV. We use App center to generate release builds. The environment always defaults to .env.development when I set NODE_ENV to production.

Steps I do is as follows:

NODE_ENV=production
react-native start --reset-cache
react-native run-ios
@github-actions
Copy link

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/209

@goatandsheep
Copy link
Owner

In my experience, it works better to set the environment variable on the same line as your server. What operating system are you on?

@snab88
Copy link
Author

snab88 commented Jul 27, 2021

In my experience, it works better to set the environment variable on the same line as your server. What operating system are you on?

Thanks for your reply. Its run in App center VMs which are macOS for react native.

@goatandsheep
Copy link
Owner

goatandsheep commented Jul 27, 2021

Try

> NODE_ENV=production react-native start --reset-cache

Instead of

> NODE_ENV=production
> react-native start --reset-cache

@snab88
Copy link
Author

snab88 commented Jul 27, 2021

Try

> NODE_ENV=production react-native start --reset-cache

Instead of

> NODE_ENV=production
> react-native start --reset-cache

It works like that if I try locally. But the issue is that on a remote VM the metro bundler starts automatically before build so I wont have much control over what passed in the command

@goatandsheep
Copy link
Owner

okay I understand now. this is a common issue. You'll need to check out custom signing of your app as well as using variant / configuration / bundle options addressed in the wiki https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting#react-native-cli

Let me know if this works

@stale
Copy link

stale bot commented Sep 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Sep 25, 2021
@stale stale bot closed this as completed Oct 2, 2021
@JameDodgers
Copy link

okay I understand now. this is a common issue. You'll need to check out custom signing of your app as well as using variant / configuration / bundle options addressed in the wiki https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting#react-native-cli

Let me know if this works

Could you give me an example on how to do it? I was thinking in setup different values for NODE_ENV based on which buildType I'm assembling, but I don't know very much about gradle and everything I tried until now failed 😔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants