Question

I'm having a problem with a NPM post-install script, the issue is that the build process ignores the configured NODE_ENV (set via cctrlapp x/y config.add) and always defaults to production. For what I've seen this was "resolved" two months ago by Heroku. From this issue, it seems that it should be transparent.

Is there something I must do to have access to my ENV variables during the build? Any workaround?

Thanks!

Was it helpful?

Solution

I found a workaround, from the different ENV vars the only one with a value during the build is DEP_NAME, but it's enough since we can extract the env from it: project/environment. This works in CloudControl, no idea if it would work in Heroku.

if ('DEP_NAME' in process.env) {
    process.env.NODE_ENV = process.env.DEP_NAME.split('/')[1];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top