I'm using this with Jenkins.
if (fileExists('.nvmrc')) {
sh 'bash -l -c "(((nvm install > /dev/null) && nvm use) && nvm alias default node) || true"'
}
corepack is available and if not install it; then enable corepack and try to install yarn@3.4.1 (the same version is specified in package.json as the "packageManager": "yarn@3.4.1" propertysh "bash -l -c '(corepack --version || npm i -g corepack) && corepack enable && corepack prepare yarn@3.4.1 --activate'"
However, the last step (corepack prepare yarn@3.4.1 --activate) fails producing the following error message:
16:14:42 Internal Error: Server answered with HTTP 503
16:14:42 at ClientRequest.<anonymous> (/usr/local/nvm/versions/node/v16.15.1/lib/node_modules/corepack/dist/corepack.js:3933:31)
16:14:42 at Object.onceWrapper (node:events:642:26)
16:14:42 at ClientRequest.emit (node:events:527:28)
16:14:42 at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:631:27)
16:14:42 at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
16:14:42 at TLSSocket.socketOnData (node:_http_client:494:22)
16:14:42 at TLSSocket.emit (node:events:527:28)
16:14:42 at addChunk (node:internal/streams/readable:315:12)
16:14:42 at readableAddChunk (node:internal/streams/readable:289:9)
16:14:42 at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
I ran the command individually, so I can confirm that it is the last one that produces the error.
Please, help.
After experiencing this error on Gitlab, switching up the runners helped resolve it.
Based on the discussion here [1], it seems the root cause might be some block-listing of IPs by Cloudflare.
Changing the source of the requests seems to have helped resolve the issue.
[1] https://github.com/yarnpkg/berry/discussions/5072