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.