Add support for custom .npmrc#79
Conversation
|
@rykov do you know how this change affects apps that don't have a If possible, please add a test for this. I just posted some info on how to do that at https://discussion.heroku.com/t/best-practices-for-testing-buildpacks/294/2 |
|
I've tried this change for apps with and without the That said, I'll get that test taken care of. |
|
@zeke I've added a test case that overrides the registry and thus fails. What do you think? |
|
🤘 |
|
@zeke 🍻 How soon would this go to production? |
|
To be on the safe side, I'll wait until Monday when I'm back at work. In the meantime there's always: |
|
Cool. Thanks |
|
This is in production now. It will take a few minutes to propagate. |
|
Great, thanks! I'll update our documentation. |
|
We're releasing a blog post tomorrow about the new buildpack. Perhaps I should add a section about support for custom config? If you do end up updating that documentation, please send it my way so I can cheat. :) |
|
I've added the npmrc section to our Heroku article and yours: Please let me know if you need any more info. |
|
Does this mean that |
|
I haven't tested it, but if it's not working, please make sure you have the user-env-compile lab enabled. |
|
Thanks for the response. I do have it enabled, though it's entirely possible I'm doing something else wrong. |
|
Related: we will soon (in the next two weeks or so) be rolling out a platform-wide replacement to user-env-compile which will be enabled by default for all apps. This means that your config vars will be available as environment variables during @matthewwithanm were you able to get it working? You could try creating a postinstall task as a sanity check to make sure the environment variables are indeed available. In package.json: {
"scripts": {
"postinstall": "echo here comes the env && env"
}
} |
|
Sounds good about the env vars—seems like a long time coming! No, I haven't gotten it working yet, though I know the vars are available during the install because I can use them in my .npmrc. I wonder if it's a case of npm not using the env vars when the userconfig option is set? |
|
Let's find out! Give this new branch a try: |
|
So sorry—it looks like npm is using the env vars! I have no idea what I was doing incorrectly yesterday. Not enough sleep, I suppose. So sorry to have wasted your time, @zeke! |
|
No problem; I'm glad we got to the bottom of it. What are the env vars you're using and how did you find out about them? I find npm's documentation of this stuff to be pretty shoddy. |
|
Yeah, unfortunately, it's not very well documented. I just stumbled across this in the docs for npm-config. Basically, it allows you to set any of the config options normally set with command line flags or npmrc…almost. My use case is to tell heroku to use my private registry (and provide credentials for it). Unfortunately, this doesn't seem to be possible with the env vars alone. That's because npm doesn't expose a "password" option and the "auth" setting in npmrc (which stores a base64'd "username:password" string) is underscore-prefixed and npm doesn't pass those through. My initial thought was to include the credentials in My current solution (which I'm not completely thrilled with) is to commit the following .npmrc file to my repo: Since .npmrc interpolates environment variables, this lets me just set |
|
Oy vey. Cool about the |
|
Nah, just .npmrc AFAIK. |
|
We solved it with a custom buildpack that we run before the nodejs buildpack It uses a config var for the .npmrc contents so that we don't have to commit the .npmrc file to our repo. |
|
I wrote one too! It detects an |
Signed-off-by: Himanshu Tiwari <himanshu.tiwari@salesforce.com>
This is to address the issue of supporting a custom registry from Issue #68 - I've tested this to work with and without a custom
.npmrcfile.