sohel16
sohel16

Reputation: 1

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

{process.env.REACT_APP_NAME}

i also dont get any error in cmd

Upvotes: 0

Views: 669

Answers (1)

Red Baron
Red Baron

Reputation: 7642

well you have REACT_APP_URL in dev but you're trying to access REACT_APP_NAME so of course it doesn't work

change this: REACT_APP_URL="DEVELOPMENT" to REACT_APP_NAME="DEVELOPMENT and it should work

Upvotes: 1

Related Questions