React: Unenable to read environment specific .env

Created on 9 Jun 2019  路  3Comments  路  Source: facebook/react

I am creating React app with Visual studio 2017 template

I have created .env.qa and .env.staging in root of ClientApp

packages.json

"scripts": {
"start": "rimraf ./build && react-scripts start env-cmd -f .env.qa", // some I may need to call qa config
"build": "react-scripts build", // for production push
"build:staging": "env-cmd .env.staging react-scripts build", // for staging push
"build:qa": "env-cmd .env.qa react-scripts build --env=qa", // for qa push
"test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint ./src/"
}

.csproj

`




`
My exception is to override variables on qa and staging

Support Redirect

Most helpful comment

You need to install the dotenv package, and import it as early as possible on your App mount with import dotenv from 'dotenv'

All 3 comments

You need to install the dotenv package, and import it as early as possible on your App mount with import dotenv from 'dotenv'

Issue is version "env-cmd": "8.0.2",
when I am updating to latest one its not working other wise working as expected

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hnordt picture hnordt  路  3Comments

zpao picture zpao  路  3Comments

jimfb picture jimfb  路  3Comments

varghesep picture varghesep  路  3Comments

trusktr picture trusktr  路  3Comments