Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running build script with env-cmd in Windows tries to open the .env file #62

Closed
Kizmar opened this issue May 8, 2019 · 2 comments
Closed

Comments

@Kizmar
Copy link

Kizmar commented May 8, 2019

react-scripts v3.0.0 (also tried with 2.1.8)
env-cmd v9.0.1

I just upgraded packages on an older project and the build stopped working. When I try to run the build script locally in Windows it is showing a "How do you want to open this file" prompt to open the ".env.vnext" file. If I do a plain yarn build, it works as expected.

Here's the script in question:
"build:vnext": "env-cmd .env.vnext react-scripts build" => yarn build:vnext

I deleted the node_modules and yarn.lock files and ran yarn install again to make sure there wasn't something weird with package versions. I also tried reverting the react-scripts version back to 2.1.8. Neither of those fixed it.

I then reverted the env-cmd package back to version to 8.0.2, and yarn build:vnext works again.

[EDIT] This might be somewhat related to issue #61, but my scenario is different enough that I figured I'd type it up.

@Kizmar Kizmar changed the title Running build script with env-cmd in windows tries to open the .env file Running build script with env-cmd in Windows tries to open the .env file May 8, 2019
@toddbluhm
Copy link
Owner

toddbluhm commented May 8, 2019

The options have changed in v9. You need to pass the -f flag if you want to provide a custom env file path (by default with no -f flag it looks for ./.env file). I will update the Readme to make that more apparent. Thanks for bringing this up. It was not a change I made lightly, but was necessary to better future proof the lib.

@Kizmar
Copy link
Author

Kizmar commented May 8, 2019

Confirmed that using "build:vnext": "env-cmd -f .env.vnext react-scripts build", does work as expected. Thank you! Easy fix. :)

@Kizmar Kizmar closed this as completed May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants