question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reload the app when .env file is edited

See original GitHub issue

Description

The environment variables are not being loaded correctly

Expected behavior

I want to use process.env + .env file to load my environment variables.

Actual behavior

I’m trying to use process.env but it have just an empty Object.

The NODE_ENV doesn’t exist either.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): └── react-scripts@0.6.1
  2. node -v: v6.7.0
  3. npm -v: 3.10.8

Then, specify:

  1. Operating system: Windows 10 Pro
  2. Browser and version: Chrome 53.0.2785.143 m

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
furlanraphacommented, Oct 7, 2016

@mikefrancis I don’t know why, but I have closed the cmd (terminal for Linux/OSX) and reopened and it started working.

Just to warn you, when you make changes to the .env file you have to stop the application and run npm start again.

Hope this helps you and another person in the future.

3reactions
gaearoncommented, Oct 10, 2016

If you guys can add some bind to the .env file so: when we update it, it already reloads the application with the new environment variables (this would be great)

This is the behavior I’d like to see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React reload .env variables after Changing them
in my react app I have a .env file and every time I change them I can't see the change until I stop...
Read more >
How To Enable Hot Reloading for .env Files in Next.js
In this article, you learned how to enable hot loading of .env files on Next.js. Finally, Next.js has extended the Fast Refresh feature...
Read more >
Breaking: Fast Refresh for .env files in Next.js 12.3
Hot Reload generally reloads the whole app on change of a file. Fast Refresh only reloads the file that is changed. If you...
Read more >
how to make changes in .env file without reloading server
I am using a form from front end to change my .env file variable values, after changing the values, changes are being saved...
Read more >
Environment Variables | Best Practices | PM2 Documentation
... pm2 restart app --update-env. Ecosystem process file. Any time you change the ecosystem process file, the environment variables will be updated.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found