Closed Djaler closed 2 years ago
At the moment there is no configuration for proxies, but it'd be nice to have
Can I help you with this?
For sure! This is the place where we handle https queries; adding support for HTTPS_PROXY there would be appreciated:
https://github.com/nodejs/corepack/blob/main/sources/httpUtils.ts#L11-L23
I think we could use https://github.com/gajus/global-agent. And https://github.com/np-maintain/global-tunnel if we need to support node < 10 (I didn't found info about node versions supported by corepack)
So, I have a two questions:
.npmrc
configShould we support node <10?
I'd go with no, as those version are past LTS.
Where should we get proxy config from? I suggest auto load variables from env (HTTP_PROXY, HTTPS_PROXY, etc)
Env variables are fine, but I'd prefer to hold off on complexifying the configuration by reading the .npmrc
(cf this other comment). It opens many questions, and the answers aren't as easy as env configuration.
Hi, there!
I'm having the same problem here. I've installed corepack, enabled it, but can't run yarn. Always get this "Error when performing the request" error, and i'm behind a proxy.
Was this problem solved?
Thanks!
@BrunoMBento PR with proxy support is created, it only needs to be merged
Thanks a lot, @Djaler !
Same problem, with proxy configured in the environment:
node: v16.13.2 SO: Ubuntu 21.10
Internal Error: Error when performing the request
at ClientRequest.<anonymous> (/usr/lib/node_modules/corepack/dist/corepack.js:3937:20)
at ClientRequest.emit (node:events:390:28)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
I have the same error. Does anyone know any workaround? Thanks! node: v17.6.0 SO: Ubuntu 21.10
Same problem here.
Workaround for now: don't use corepack i guess:
corepack disable
npm install -g yarn
yarn config set registry YOUR_URL
yarn config set npmRegistryServer YOUR_URL
// for yarn2
yarn config set httpProxy localhost:8887
// maybe 🤷♂️
And don't forget to delete your local yarn.lock file in the project folder as our industry is fucked up and it caches the initial URLs for each dependency, even if you changed the registry config inbetween 🙄
Any updates on this?
By the way, @icyerasor , if I disable the corepack
, then even if I install it using npm
, I don't have yarn
command!
So, your workaround doesn't work for me.
Any other alternative ways?
I had the "Internal Error: Error when performing the request" at "corepack.js:3937:20" like everyone who's been here so I looked in line 3937 and discovered it was a vanilla https.get call. I stuck in some extra debugging and discovered it was failing trying to reach "https://registry.npmjs.com/pnpm".
I navigated to "https://registry.npmjs.com/pnpm" in my web browser and discovered my corporate environment let it load up with no errors. So I fired up Node JS and issued to see what would happen:
https.get("https://registry.npmjs.com/pnpm", {}, res => console.log(res));
I received a "unable to get local issuer certificate" error. In my corporate environment, there's a security solution that injects it's own self-signed certificates into responses from any outbound https requests. What that means for me is that I need to instruct anything issuing https requests (eg Node.js and curl) to use a custom CA certificate file.
To get corepack to work, I first hard-coded a custom CA certificate file into corepack.js and while it's pretty ugly, it did work. A bit of further digging around I found the NODE_EXTRA_CA_CERTS environment variable option used by Node.js so also tried the following in a Administrator-privileged cmd session with success (also removing the corepack.js hack I made earlier):
set NODE_EXTRA_CA_CERTS=c:\temp\combo.ca.cer
corepack enable
yarn set version stable
The combo.ca.cer was constructed by navigating to https://registry.npmjs.com/pnpm and exporting all the CA certs (root and any intermediate CA certs) to text files and copy-pasting the contents of all the CA cert files into a single text file called combo.ca.cer. I used advice from https://stackoverflow.com/a/44726189 to create my custom CA cert file.
In case it helps anyone, our firewall blocks any tarball or exe and while debugging I noticed an attempt on 'https://registry.yarnpkg.com/yarn/-/yarn-1.22.19.tgz' which is causing this error in our case.
In case anyone missed it, as of Corepack 0.11.0, HTTP_PROXY
, HTTPS_PROXY
, and NO_PROXY
are supported through node-proxy-agent
.
I'd love any advice that anyone has for using HTTP_PROXY
and other env variables to configure a custom package manager! We're trying to get pnpm to install from a corporate Nexus repo.
In case anyone missed it, as of Corepack 0.11.0,
HTTP_PROXY
,HTTPS_PROXY
, andNO_PROXY
are supported throughnode-proxy-agent
.
Could you elaborate a little bit? I am behind proxy, HTTP_PROXY
and HTTPS_PROXY
environment variables are set, proxy-agent is installed, but no joy installing yarn
via corepack
:
$ corepack install -g yarn
Internal Error: Error when performing the request to https://repo.yarnpkg.com/tags; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
at fetch (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22882:11)
at async fetchAsJson (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22896:20)
at async fetchAvailableVersions2 (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23002:20)
at async /usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23428:25
at async Promise.all (index 1)
at async Engine.resolveDescriptor (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23425:22)
at async InstallGlobalCommand.installFromDescriptor (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23835:22)
at async InstallGlobalCommand.execute (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23821:9)
at async InstallGlobalCommand.validateAndExecute (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21173:22)
at async _Cli.run (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22148:18)
In case anyone missed it, as of Corepack 0.11.0,
HTTP_PROXY
,HTTPS_PROXY
, andNO_PROXY
are supported throughnode-proxy-agent
.
I would also be interested in some tips on how to use proxy-agent with corepack. Thanks!
As of Corepack 0.26.0, we're now using proxy-from-env
. It should not require anything to install on your end, only setting env variable AFAIK (so HTTPS_PROXY
, or ALL_PROXY
). I recommend opening a new issue if you're need more help.
As of Corepack 0.26.0, we're now using
proxy-from-env
. It should not require anything to install on your end, only setting env variable AFAIK (soHTTPS_PROXY
, orALL_PROXY
). I recommend opening a new issue if you're need more help.
Thanks for your help! I'll open a new issue.
corepack 0.28.2 appears to have several remaining glitches concerning proxies / certificate chains.
corepack
... and yarn
... silently ignore HTTP_PROXY
, HTTPS_PROXY
, and NODE_EXTRA_CA_CERTS
when installing yarn itself.corepack
... and yarn
... silently ignore httpProxy
, httpsProxy
, and httpsCaFilePath
in .yarnrc.yml
when installing yarn itself.corepack
and yarn
silently ignore ~/.npmrc
proxy and certificate chain information when installing yarn itself.npm install -g
is hazardous. So yarn is requiring use of an experimental, unstable component to provision yarn.corepack install --global yarn@4.5.0
present no HTTP response information or socket information at all.
I tried to do, as instance
corepack prepare pnpm@5.18.10
, but gotInternal Error: Error when performing the request
. I think this is because of the proxy. Where I can configure it? I have proxy setting in.npmrc
, also I haveHTTP_PROXY
andHTTPS_PROXY
environment variables