Bug: corepack ignores COREPACK_NPM_REGISTRY for yarnpkg registry
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 279
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
Conditions for bug
npmjs.org and yarnpkg.com are blocked on my laptop
Background and things I've tried
We have an internal registry mirror which mirrors both npmjs and yarnpkg. Due to a recent supply chain attack it is a policy that my laptop blocks both npmjs and yarnpkg so I'm not able to reach them directly. All of my JS RC files are set to reach out to corporate proxy:
~/.npmrc~/.yarnrc~/.yarnrc.yml
I learned that corepack ignores all of these files and instead reaches out to registries directly. I was able to partially work around this by setting the following environment variable.
export COREPACK_NPM_REGISTRY="<my corporate proxy>"
Setting this environment variable gets me past errors for registry.npmjs.org but still triggers errors for registry.yarnpkg.com.
Potentially buggy lines of code
- https://github.com/nodejs/corepack/blob/7e0758e4fd920859ad92adf204caf766b242f1af/config.json#L119
- https://github.com/nodejs/corepack/blob/7e0758e4fd920859ad92adf204caf766b242f1af/sources/corepackUtils.ts#L233-L256
- https://github.com/nodejs/corepack/blob/7e0758e4fd920859ad92adf204caf766b242f1af/sources/npmRegistryUtils.ts#L14
Because https://registry.yarnpkg.com does not match https://registry.npmjs.org there's no proxying available.
Desired solution
- Ideally: adhere to
~/.yarnrc.yml - Or adhere to
COREPACK_NPM_REGISTRY - Or introduce a new environment variable
COREPACK_YARN_REGISTRY - Or more robust environment variable which allows one to substitute multiple registries via some kind of expression syntax.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with config.json and the registry-handling code in sources/corepackUtils.ts and sources/npmRegistryUtils.ts, especially the referenced lines. Trace how COREPACK_NPM_REGISTRY is applied to npmjs.org and why it does not cover registry.yarnpkg.com. Done means Corepack can consistently use the configured proxy for the Yarn registry, with the supported configuration behavior clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100