0

Can't seem to load .env variables using create-react-app --template=typescript not sure what I'm missing. Can anyone help out? process.env.REACT_APP_GRAPHQL variable is undefined and process.env just returns an empty object.

Using "react-scripts": "3.4.1"

EDIT: figured it out answer below

Josh Bedo
  • 11
  • 4
  • Does this answer your question? [How to set build .env variables when running create-react-app build script?](https://stackoverflow.com/questions/42458434/how-to-set-build-env-variables-when-running-create-react-app-build-script) – Jared Smith Dec 18 '20 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. – Jared Smith Dec 18 '20 at 15:26
  • nvm I just saw your self answer. Which is fine, but please update the question as well. – Jared Smith Dec 18 '20 at 15:27

2 Answers2

0

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

Shayan
  • 238
  • 4
  • 11
0

false flag, found out VScode was trying to be smart and auto-imported module "process" at the top which overwrote the actual process.env variables being sent through. Just had to remove the "process" module to fix things didn't even notice it being imported.

Josh Bedo
  • 11
  • 4