Next.js: with-dotenv example when changing .env changes doesn't get applied

Created on 8 Jul 2018  路  5Comments  路  Source: vercel/next.js

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 = '[email protected]' to REACT_APP_EMAIL = '[email protected]'
  2. yarn build
  3. i start my application using pm2 start ecosystem.config.js
  4. is still see my old values ([email protected]) for variables when running the app

Expected behavior

to see the new values of variable which is [email protected]

good first issue

Most helpful comment

Try rm -rf node_modules/.cache

All 5 comments

Try rm -rf node_modules/.cache

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

@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

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 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

jesselee34 picture jesselee34  路  3Comments

knipferrc picture knipferrc  路  3Comments

swrdfish picture swrdfish  路  3Comments

formula349 picture formula349  路  3Comments