简体   繁体   中英

env variable undefined in create react app

I'm trying to use environment variables in my react app that I created with npx create-react-app. I created.env file(in the root directory) and placed the variable which start with REACT_APP, but still when I try to log it in the console, it shows up undefined.

I did restart development server many times, still the same.

在此处输入图像描述

在此处输入图像描述

I uploaded test project here

not sure about the reason behind this, but it did not work for me with the.env file in the attachment. So i deleted the.env file and created new one will same content and it started working

在此处输入图像描述

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