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

with-dotenv example when changing .env changes doesn't get applied #4748

Closed
FadiAboMsalam opened this issue Jul 8, 2018 · 5 comments · Fixed by #4924
Closed

with-dotenv example when changing .env changes doesn't get applied #4748

FadiAboMsalam opened this issue Jul 8, 2018 · 5 comments · Fixed by #4924
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@FadiAboMsalam
Copy link

FadiAboMsalam commented Jul 8, 2018

Example name

with-dotenv

Describe the bug

i have followed this with-dotenv example and it works as expected fist time then i did a change on the .env file but it seems the first values of .env is still loaded

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. define some variable inside .env lets say we want to change REACT_APP_EMAIL = 'x@gmail.com' to REACT_APP_EMAIL = 'x2@gmail.com'
  2. yarn build
  3. i start my application using pm2 start ecosystem.config.js
  4. is still see my old values (x@gmail.com) for variables when running the app

Expected behavior

to see the new values of variable which is x2@gmail.com

@timneutkens
Copy link
Member

Try rm -rf node_modules/.cache

@timneutkens timneutkens added help wanted good first issue Easy to fix issues, good for newcomers labels Jul 8, 2018
@maxbeatty
Copy link

is pm2 restarting the process entirely when you make changes to your .env file? dotenv will not overwrite existing values in process.env so it needs a fresh process for you to see your changes

@FadiAboMsalam
Copy link
Author

@timneutkens you are close enough if i delete my node_modules and re install them then building the app once again and run it through pm2 it reloads the .env variables
but i have no idea why does it cache and i don't think this is the solution to go but at least it is a work around

@timneutkens
Copy link
Member

i don't think this is the solution to go but at least it is a work around

That's why I added the labels instead of closing immediately 😄

@HaNdTriX
Copy link
Contributor

HaNdTriX commented Aug 8, 2018

Related Issue: brysgo/babel-plugin-inline-dotenv#13

timneutkens pushed a commit that referenced this issue Aug 8, 2018
## Issue

I decided to rewrite the [with-dotenv](https://github.com/zeit/next.js/tree/canary/examples/with-dotenv) using [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack) example because:

- changes doesn't get applied  (#4748, brysgo/babel-plugin-inline-dotenv#13)
- the production mode doesn't work at all
- this approach has already been used in the [examples/relay-modern](https://github.com/zeit/next.js/blob/9320d9f006164f2e997982ce76e80122049ccb3c/examples/with-relay-modern/next.config.js)
- it is [documented](https://webpack.js.org/plugins/environment-plugin/#dotenvplugin) by webpack

## Alternatives

* remove/deprecate example
* fix babel-plugin-inline-dotenv

## Related

Closes: #4748
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants