2

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!

jgillich
  • 71,459
  • 6
  • 57
  • 85
doup
  • 841
  • 1
  • 9
  • 20

1 Answers1

3

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];
}
doup
  • 841
  • 1
  • 9
  • 20
  • The 'DEP_NAME' is indeed available. We also provide a special environment variable to determine if the buildpack is running. It's called 'BUILDPACK_RUNNING'. – pst Apr 22 '14 at 07:02