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

How to avoid installation of devDependencies when environment is *not* production #355

Closed
adamreisnz opened this issue Dec 17, 2016 · 5 comments

Comments

@adamreisnz
Copy link

adamreisnz commented Dec 17, 2016

We have several environments for our app, e.g. dev, staging, demo and production.
We use the NODE_ENV variable to set the correct environment, which in turn then loads the correct configuration etc. for each environment.

The problem is that npm install (or yarn for that matter) will install devDependencies also for our staging and demo environments.

How can we prevent this and force the build to only install the production dependencies while leaving NODE_ENV unchanged?

@adamreisnz
Copy link
Author

I've resorted to dropping our app's dependency on NODE_ENV and introduced an APP_ENV instead. This way, configuration etc. can use the APP_ENV setting, while the build process can use the dedicated NODE_ENV.

Not ideal, but given the various constraints this was the best solution I could come up with. If anyone has other idea's I'd love to hear them.

@hunterloftis
Copy link
Contributor

That's a reasonable solution; additionally, Yarn now supports YARN_PRODUCTION as an analogue to NPM_CONFIG_PRODUCTION. The next release of the buildpack will map one to the other to make yarn behave more like npm on Heroku.

@hunterloftis
Copy link
Contributor

#359

@adamreisnz
Copy link
Author

I've tried to use the YARN_PRODUCTION flag, but that also changes what scripts see as NODE_ENV to production, so it didn't solve our problem.

The separate APP_ENV seems to be the best approach so far, it's given us a lot more flexibility and control.

@hunterloftis
Copy link
Contributor

@adamreisnz that's a good general solution for both yarn and npm (the NODE_ENV internal setting isn't specific to yarn - npm does the same thing).

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