[英]Set env Variables in react project
Someone please help me with below有人请在下面帮助我
i have installed npm i env-cmd
i have 2 files in the src folder
.env.development
REACT_APP_URL="DEVELOPMENT"
.env.production
REACT_APP_NAME="PRODUCTION"
package.json file
"start": "env-cmd .env.development react-scripts start",
"build": "env-cmd .env.production react-scripts build",
But i get nothing while do this in app.jsx但是在 app.jsx 中执行此操作时我什么也没得到
i also dont get any error in cmd我在 cmd 中也没有收到任何错误
well you have REACT_APP_URL
in dev but you're trying to access REACT_APP_NAME
so of course it doesn't work好吧,您在 dev 中有
REACT_APP_URL
但您正在尝试访问REACT_APP_NAME
所以它当然不起作用
change this: REACT_APP_URL="DEVELOPMENT"
to REACT_APP_NAME="DEVELOPMENT
and it should work改变这个:
REACT_APP_URL="DEVELOPMENT"
到REACT_APP_NAME="DEVELOPMENT
它应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.