From @jayair on Fri Dec 01 2017 18:45:01 GMT+0000 (UTC)
Link to chapter - https://serverless-stack.com/chapters/environments-in-create-react-app.html
Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/168
It should probably be noted at the top of this section that this tutorial relates to the project completed in Part I.
Good point. Iāll add a note.
I am getting this error on windows machine.
āREACT_APP_STAGEā is not recognized as an internal or external command,
Cant find any related solution.
I think this has to do with the command line format. I donāt know the windows version too well. But if you can figure out how to run this on your machine, you should be good.
$ REACT_APP_TEST_VAR=123 npm start
I believe Iām running into the same problem on Windows. Were you able to find a solution?
Thanks!
-Derek
Iām not super familiar with how to set things for Windows. Hopefully somebody can help out.
I was able to get it working using cross-env. I had to install the package and use the syntax below:
āstartā: ācross-env REACT_APP_STAGE=dev react-scripts startā,
ābuildā: āreact-scripts buildā,
ātestā: āreact-scripts test --env=jsdomā,
āpredeployā: ācross-env REACT_APP_STAGE=dev npm run buildā,
Thanks!
-Derek
Is this for Windows?
If youāre in Windows, you should change command to āset REACT_APP_STAGE=xxx && npmā¦ā
Hi. I deployed the app in dev and prod environments in AWS S3. Everything OK, until I found that the production app is using dev resources (Cognito, database, etc). Anyone can tell me how to set the REACT_APP_STAGE variable in the S3 bucket?
So the environments are set while building the app. So the REACT_APP_STAGE=prod npm run build
is setting it.
I finally solved it having two versions of the .env file (.env.dev and .env.prod) and copy the environment file to .env when deploying to each one.
I see. Yeah that works.