3

My console keeps on saying that "To set up the editor integration, add something like REACT_EDITOR=atom to the .env.local file in your project folder and restart the development server. Learn more"

I cant even find the .env file on my create-react-app.

Thank you in advance.

1 Answers1

6

Create-React-App supports custom environment variables.

The documentation discusses how to declare these variables:

This can be done using two ways: either in your shell or in a .env file. Both of these ways are described in the next few sections.

Through the local environment

The first way is to add it to your local environment:

For instance, if you're using bash, edit ~/.bashrc

Add export REACT_APP_EDITOR=atom to the bottom then restart your terminal (or source ~/.bashrc)

Through .env files in your application

The second way is to create a .env file at the root of your application directory, and add the variable on a single line there:

REACT_APP_EDITOR=atom

From the documentation, these types of files can be declared and will be consumed by Create-React-App:

.env: Default.
.env.local: Local overrides. This file is loaded for all environments except test. .env.development, .env.test, .env.production: Environment-specific settings.
.env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.

giraffesyo
  • 4,860
  • 1
  • 29
  • 39
  • Why would the warning message specifically mention the `.env.local` file then, if the change should be made to the login shell? – Ben Voigt Oct 18 '18 at 18:00
  • @BenVoigt I've updated my answer to address the different variations and app specific `.env` files. – giraffesyo Oct 18 '18 at 18:12