yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.4k stars 2.73k forks source link

[Bug?]: The registry of Yarn is set using the IP address:port/npm. However, Yarn fails to obtain resources from the IP address:port/npm. #9053

Open majestichou opened 5 months ago

majestichou commented 5 months ago

Self-service

Describe the bug

An npm image source exists and its address is http://ip:port/npm/. Run the following command to set the registry: yarn config set registry http://ip:port/npm/ . Then I installed pm2 with the following command: yarn global add pm2 The installation fails. The following error information is displayed: error An unexpected error occurred: "http://ip/npm/chalk/-/chalk-3.0.0.tgz: Request failed \"404 Not Found\"". From the above error message, it can be seen that I have set the port, but the yarn does not take effect. Yarn should not obtain resources from http://ip/npm/chalk/-/chalk-3.0.0.tgz. Instead, it should obtain resources from http://ip:port/npm/chalk/-/chalk-3.0.0.tgz. The port setting does not take effect. Then I use Chrome to visit http://ip:port/npm/chalk/-/chalk-3.0.0.tgz address, normally downloaded the installation package. This proves that there is no problem with the server, yarn has a bug. My yarn version is 1.22.19

To reproduce

  1. Create a Dockerfile and write the following content:
    
    FROM node:20.11-alpine3.19 AS base

RUN yarn config set registry http://ip:port/npm/

RUN yarn global add pm2

2. `docker build . -t test`
3. Error is as follows
`error An unexpected error occurred: "http://ip/npm/chalk/-/chalk-3.0.0.tgz: Request failed \"404 Not Found\"".`

### Environment

```shell
yarn dlx -q envinfo --preset jest
yarn run v1.22.19
error Command "dlx" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context

No response