Skip to content

Yarn install package from gitlab registry failed in a Pipeline: Request failed \"404 Not Found\""

Summary

I can't install an npm package from Gitlab Package registry in a Pipeline because of an unexpected error Locally evything works but in the CI yarn fails to install the private package.

Steps to reproduce

What is the current bug behavior?

$ yarn
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://gitlab.com/api/v4/projects/31921697/packages/npm/@org/ban-client/-/@org/package-1.0.1.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "/builds/org/api/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

What is the expected correct behavior?

It should install the package from gitlab registry,

yarn add v1.22.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Workspaces can only be enabled in private projects.
success Saved 1 new dependency.
info Direct dependencies
└─ @org/package@1.0.1
info All dependencies
└─ @org/package@1.0.1
Done in 1.20s.

Relevant logs and/or screenshots

My .npmrc config:

@org=https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken=XXX

Results of GitLab environment info

Gitlab Runner: 14.8.2 npm: 8.1.2 node: 16.13.1

Possible fixes