0

I can't seem to load .env variables using create-react-app --template=typescript and am not sure what I'm missing. How can I fix it? The process.env.REACT_APP_GRAPHQL variable is undefined and process.env just returns an empty object.

I am using "react-scripts": "3.4.1"

3
  • Does this answer your question? How to set build .env variables when running create-react-app build script? Commented Dec 18, 2020 at 15:25
  • You have to actually create a .env file that defines them. This covered extensively in the documentation, and a quick google search came up with dozens of tutorials. Commented Dec 18, 2020 at 15:26
  • nvm I just saw your self answer. Which is fine, but please update the question as well. Commented Dec 18, 2020 at 15:27

2 Answers 2

0

You can find the complete answer in the create-react-app docs about environment variables.

Sign up to request clarification or add additional context in comments.

Comments

0

It was a false flag. I found out Visual Studio Code was trying to be smart and auto-imported module "process" at the top which overwrote the actual process.env variables being sent through.

I just had to remove the "process" module to fix things. I didn't even notice it being imported.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.