简体   繁体   中英

How to get .env variables with Create-React-App --template typescript?

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM