zetachang / react-native-dotenv

A Babel preset let you import application configs from .env file (zero runtime dependency)
MIT License
915 stars 68 forks source link

Variables are not updating #24

Closed wachunei closed 7 years ago

wachunei commented 7 years ago

Variables defined in .env are not updating.

I've tried:

  1. Changing the file (add blank lines, whitspace)
  2. Restarting the packager (Ctrl + C; yarn start)
  3. 1 and 2 together
  4. Running react-native run-X again
  5. 3 and 4 together

😞 Don't know what else to try

wachunei commented 7 years ago

Figured it out: had to make any changes on the code too for it to update.

josomers commented 7 years ago

@wachunei running the packager with --reset-cache will do the trick as well.

pencilcheck commented 6 years ago

It seems like if you are using detached expo project you can also do this exp --tunnel --clear that will remove cache on server starts

ofaucorp commented 6 years ago

@wachunei same trick works for me as well. i tried a lot of tries to fix but your approach fixed my issues. thanks you very much.

dominikznidar commented 5 years ago

For me tests were not picking up changes in .env when calling yarn test. I resolved it by calling yarn test --clearCache.

6thpath commented 5 years ago

@wachunei running the packager with --reset-cache will do the trick as well.

where should i put --clear-cache

jerodb commented 5 years ago

--reset-cache worked for me.

@lPaths --reset-cache should be used when you start the React Native packager: $ node node_modules/react-native/local-cli/cli.js start --reset-cache or $ react-native start --reset-cache

If you start it from your package.json scripts:

{
  ...
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  ...
}

$ yarn start --reset-cache
Dsantacruz commented 4 years ago

Manually edit the file importing react-native-dotenv by either adding an empty line or whitespace will work.

https://www.npmjs.com/package/react-native-dotenv#faq