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

No way to get production dependencies without NODE_ENV=production #465

Open
holm opened this issue Aug 17, 2017 · 3 comments
Open

No way to get production dependencies without NODE_ENV=production #465

holm opened this issue Aug 17, 2017 · 3 comments

Comments

@holm
Copy link

holm commented Aug 17, 2017

In our staging environment we would like to use NODE_ENV=staging, but still only get production dependencies installed. That does not seem possible with the buildpack.

We use https://www.npmjs.com/package/config to manage configuration, which is based on NODE_ENV. This needs to be set correctly during install, as we use heroku-postbuild package script to compile bundles, and this depends on the configuration.

@jmorrell
Copy link
Contributor

Hi! If you set NPM_CONFIG_PRODUCTION=true you should still only install production dependencies, even with NODE_ENV=staging

heroku config:set NPM_CONFIG_PRODUCTION=true

@holm
Copy link
Author

holm commented Aug 17, 2017

Yes but as I wrote in the description this changes the NODE_ENV, which has effects on the post build script, since the env will now always be production.

I find it a bit strange that the way to get not get dev dependencies is to overwrite the NODE_ENV, instead of just using the --production flag.

@Khauri
Copy link

Khauri commented Jun 11, 2020

My team has also been having this issue as we have a staging dyno that builds our slug before we promote that slug to production. And we didn't want the devDependencies to be included in the slug, so we set NPM_CONFIG_PRODUCTION. But because of this our staging dyno is now being run with NODE_ENV=production, which is causing problems for us.

For now we've had to use a separate environment variable APP_ENV which we've set NODE_ENV to right after booting up.

I've looked through this repo and couldn't immediately find where/how the npm install command is run, but would it be possible to have an env variable that either sets NPM_CONFIG_PRODUCTION only on the install command, or maybe some sort of configuration for the install command itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants