Closed arcanis closed 8 months ago
I'm starting to desentangle that in #340, although I'll also need to tweak @yarnpkg/cli-dist
so that its tags match the ones from /repo
(latest
currently points to canary
on our npm releases, whereas we'd want them to point to stable
instead).
I feel like I'm missing something here:
USER root
...
ARG NODEJS_VERSION='18.19.0'
ENV PATH "/opt/node/bin:$PATH"
RUN mkdir -p /opt/node \
&& tar -xzf /installers/node-v${NODEJS_VERSION}-linux-x64.tar.gz --directory=/opt/node --strip-components=1 --no-same-owner
USER jenkins
# Configure npm & install+configure Yarn.
ARG YARN_VERSION='4.1.0'
ARG NPM_REGISTRY_URL='https://nexus.corp.internal/repository/npmjs-proxy/'
ENV COREPACK_NPM_REGISTRY $NPM_REGISTRY_URL
ENV NPM_CONFIG_PREFIX ${HOME}/.npm-global
ENV PATH ${NPM_CONFIG_PREFIX}/bin:$PATH
RUN npm config set registry $NPM_REGISTRY_URL \
# Node 18.19.0 ships with corepack 0.22.0, but we need corepack 0.24.0+
&& npm install --global corepack@latest \
&& corepack enable \
&& corepack --version \
&& corepack install --global yarn@${YARN_VERSION} \
&& yarn config set --home npmRegistryServer $NPM_REGISTRY_URL
Results in:
0.24.1
Installing yarn@4.1.0...
Internal Error: Error when performing the request to https://repo.yarnpkg.com/4.1.0/packages/yarnpkg-cli/bin/yarn.js; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
at ClientRequest.<anonymous> (/home/jenkins/.npm-global/lib/node_modules/corepack/dist/lib/corepack.cjs:42208:16)
at ClientRequest.emit (node:events:517:28)
at TLSSocket.socketErrorListener (node:_http_client:501:9)
at TLSSocket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
@arcanis I'm not sure why corepack is still trying to connect to repo.yarnpkg.com
instead of respecting the COREPACK_NPM_REGISTRY
.
This is a corporate machine with no direct internet access ;).
@PayBas did you ever find out why this was happening?
It's been mentioned a couple of times that Yarn publishing its versions on its own was inconvenient for people using private npm mirrors. I'd prefer to keep using our store by default, but it makes sense to offer a way to fallback to the npm store when requested. This diff changes the logic so that we use the
@yarnpkg/cli-dist
package when theCOREPACK_NPM_REGISTRY
variable is set. It should be backward-compatible, since theregistry
field is still the same.Fixes #337