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

Version 9.x breaks usage on react-scripts build #71

Closed
UplandsDynamic opened this issue Jun 5, 2019 · 3 comments
Closed

Version 9.x breaks usage on react-scripts build #71

UplandsDynamic opened this issue Jun 5, 2019 · 3 comments

Comments

@UplandsDynamic
Copy link

I'm not sure exactly what's going on here, but there appears to have been a breaking change between versions 8.0.2 and 9.0.0 which causes failure of my react-scripts builds.

I'm building on Ubuntu 18.04. The problem also exists and exhibits identical behaviour when building in a Debian Stretch environment in Docker.

The relevant part of my package.json:

"scripts": {
    "build:production": "env-cmd .env.production react-scripts build"
  },

The error:

> my_test_app@3.0.1 build:docker /home/dev/react
> env-cmd .env.docker react-scripts build
Error: Unable to locate env file at default location (./.env)
    at /home/dev/react/node_modules/env-cmd/dist/get-env-vars.js:44:19
    at Generator.throw (<anonymous>)
    at rejected (/home/dev/react/node_modules/env-cmd/dist/get-env-vars.js:5:65)
    at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:121:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my_test_app@3.0.1 build:docker: `env-cmd .env.docker react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my_test_app@3.0.1 build:docker script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dev/.npm/_logs/2019-06-05T22_45_47_875Z-debug.log

Versions up to 8.0.2 work flawlessly using the above scripts declaration. I have tested using exactly the same app, in the same environment, with the only different variable being the version of env-cmd. Switching to < 9.0.0 is fine, but upgrading to 9.0.0 and above breaks the build.

@toddbluhm
Copy link
Owner

toddbluhm commented Jun 6, 2019

This project does its best to adhere to semver versioning meaning any major version upgrade (1.x.x -> 2.x.x, 2.x.x -> 3.x.x, etc...) could cause breaking non-backwards compatible changes. This is the case when upgrading from version 8.x.x -> 9.x.x 🙁

In the changelog it states that the options have changed for 9.x.x and up 😄

For your specific case you need to provide the -f flag in order to read from a custom file path. So env-cmd .env.production react-scripts build -> env-cmd -f .env.production react-scripts build. This was done in order to better future proof the lib from new features that are requested in the future.

See examples repo for more specific examples regarding env file usage or you can also view the Help section of the ReadMe file (Note: you can also do env-cmd --help to view the same help menu found in the above Help section) 😄

Related to: #61

Sorry about the breakage 🙁
Thanks for using this tool and hopefully that helps clear up your issue 😃

@toddbluhm toddbluhm pinned this issue Jun 6, 2019
@UplandsDynamic
Copy link
Author

Thank you for the advice. I fully understand and respect the reasoning behind the breaking change; not a problem.

Thank also for all your hard graft on this project and for making it freely available. I'm very grateful - It's a valuable, useful tool, and your work is very much appreciated.

@toddbluhm
Copy link
Owner

Closing due to inactivity

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