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

Configurable registry for binary downloads #1193

Closed
chadhietala opened this issue Apr 25, 2021 · 3 comments · Fixed by #1621
Closed

Configurable registry for binary downloads #1193

chadhietala opened this issue Apr 25, 2021 · 3 comments · Fixed by #1621

Comments

@chadhietala
Copy link

chadhietala commented Apr 25, 2021

We use an internal artifactory instance that contains all of the packages we we need to build and those machines don't have access to the internet. Currently when we try to use esbuild it fails in CI since the installer attempts to download the public registry.

Would you be open to a PR that added npmrc support for defining the registry? I was thinking something like the sass_binary_site config.

@evanw
Copy link
Owner

evanw commented Apr 25, 2021

There is already a npm config for this: https://docs.npmjs.com/configuring-your-registry-settings-as-an-npm-enterprise-user. I remember testing this in the past using https://verdaccio.org/ and it seemed to work. Setting registry in your .npmrc should set the npm_config_registry environment variable which should persist into esbuild's nested npm invocation. Have you tried doing that already? If so, why didn't it work?

@chadhietala
Copy link
Author

TL;DR this is a Yarn problem on how it applies the npmrc. There is a work around (see below) but ideally I need to get off of Yarn.

Having dived in to this a bit more there are a couple things I think going on. We rely on the client; either npm or yarn, to read the registry the npmrc and we do not proxy all calls to public repo back internally into the private instance. This is largely a security policy on our end.

That said I think this is related to the fact that we pre-Yarn 2.0 as the initial installer and it has issues with apply .npmrc onto the process.env. I confirmed with verdaccio that doing:

yarn install # hits public npm registry without going through proxy
npm_config_registry="http://localhost:5555" yarn install # hits public npm registry without going through proxy
NPM_CONFIG_REGISTRY="http://localhost:5555" yarn install # goes through proxy
npm install #  goes through proxy

@SkReD
Copy link

SkReD commented Jul 5, 2021

Hi @evanw! Thanks for the great tool! Faced this problem from the topic but with yarn 1 and none of listed solutions worked:

  1. export NPM_CONFIG_REGISTRY
  2. export npm_config_registry
  3. yarn config set registry
  4. yarn config set registry -g

Yarn issues yarnpkg/yarn#5854 and yarnpkg/yarn#5683

Only worked solution was pre-install packages via npm install with --registry option for cache warmup. Also in docker there seems to be problem with process.env.TMPDIR and that require('os').tmpdir() is returns cwd instead of temp directory path (npm/npm#4531).

Can install script be extended with support for custom env variable for registry and with --unsafe-perm flag for correct process.env.TMPDIR value?

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

Successfully merging a pull request may close this issue.

3 participants