kHRISl33t / runtime-env-cra

Runtime environment handler for create-react-apps
MIT License
49 stars 23 forks source link

Does not generate the file runtime-env.js #3

Closed mhungc closed 3 years ago

mhungc commented 3 years ago

Hello team,

I follow the example but it generate me an issue:

image

after investigating I did this test:

"scripts": { "start": "SET NODE_ENV=development runtime-env-cra --config-name=./default/runtime-env.js"

to just generate the .js file but never generate it.

Also i play around with the example and if you delete from the ts example in the public folder the file runtime-env.js I reply the error that gives me.... so in conclusion it is not generating the .js file :(

kHRISl33t commented 3 years ago

Hey!

Sorry for the late reply, I was away for a few days, but can you provide how the folder structure of your application looks like? tree -I node_modules

Are you using creact-react-app? Did you add the script source to your index.html ?

To regenerate the runtime-env.js file, you need to stop and than restart the application.

mhungc commented 3 years ago

¡Hey dont worry!

Thanks for awnser me.

Actually i'm trying to uses you example for the ts(typescript) one but i can't generate again the runtime.js inclusive i deleted from the public folder and i ran npm start again and it doesnt create the runtime-env.js...it give me the error that i copied before.

the only thing that i changed was the command for the npm start becaouse i'm on windows so to run it locally using npm i had to pot before NODE the set word like this:

"scripts": { "start": "SET NODE_ENV=development runtime-env-cra --config-name=./public/runtime-env.js && react-scripts start",

But I'm sure it's not that ...

kHRISl33t commented 3 years ago

Oh, I see, as I'm checking your attached picture again, I can see you are on windows. Sorry, sadly I did not try it on windows before releasing it, but I will today and provide some feedback :)

mhungc commented 3 years ago

Yeah jeje :) many thanks!

seanblonien commented 3 years ago

yea Windows set NODE_ENV=development <command> syntax doesn't seem to work, but my suggestion is just use cross-env

you'd likely want to use it anyways if you're intending on supporting multiple developers on a project, and at least it's just a devDependency. small price to pay for literally just switching one word cross-env NODE_ENV=development <command> and it just working

kHRISl33t commented 3 years ago

I will update the docs accordingly, and after @seanblonien PR's will be merged, it will work correctly on windows too (with cross-env).