0

Yarn fails to install private GitLab package using instance-level registry setup.

I have successfully published a scoped package @myorg/mypackage to my GitLab instance using a project-level registry from a CI build. I can see the package my GitLab repository's Package Registry UI. I can also use browser to download the tar file. Installing the package to npm project succeeds using the instance-level registry and a personal access token.

.npmrc contents (anonymized)

@myorg:registry=https://myorgsgitlab:port/api/v4/packages/npm/
//myorgsgitlab:port/api/v4/packages/npm/:_authToken=asdf
always-auth=true

However, if I try using yarn, the installation fails with the following:

info No lockfile found.
[1/4] Resolving packages...
verbose 0.1727709 Performing "GET" request to "https://myorgsgitlab:port/api/v4/packages/npm/@myorg%2fmypackage".
verbose 0.5582721 Request "https://myorgsgitlab:port/api/v4/packages/npm/@myorg%2fmypackage" finished with status code 200.
[2/4] Fetching packages...
verbose 0.689239 Performing "GET" request to "https://myorgsgitlab:port/api/v4/projects/27/packages/npm/@myorg/mypackage/-/@myorg/mypackage-1.0.2.tgz".
verbose 0.7588204 Error: https://myorgsgitlab:port/api/v4/projects/27/packages/npm/@myorg/mypackage/-/@myorg/mypackage-1.0.2.tgz: Request failed "404 Not Found"
    at ResponseError.ExtendableBuiltin (C:\Users\vivid\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:696:66)

So I tried adding another line to .npmrc

//myorgsgitlab:port/api/v4/projects/27/packages/npm/:_authToken=asdf

The same error is still occurring.

If I change the @myorg:registry setting to the project specific address (the one with /projects/27/) the installation succeeds. However, that is not an option as I have multiple packages under @myorg scope and they come from different repositories (project ids).

  • Yarn version v1.22.18
  • GitLab version 14.9.0
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
vivid_voidgroup
  • 728
  • 5
  • 11
  • You're getting quite different results than I am (yarn 1.22.19). I found that I had to name my package "@gitnamespace/mypackagename", where "gitnamespace" was the root namespace of the GitLab project that the package was published to. If I tried to use the company name (or whatever), then yarn threw a 404 at the "Resolving packages" stage. Using the correct naming system, I can get it working with a .npmrc just like the one you posted. I would love to use "better" naming though. – Steven Frew Jul 12 '22 at 14:14
  • I should point out that when I say "just like the one you posted", I mean with the FOUR lines (extra project URL token line). – Steven Frew Jul 12 '22 at 14:35
  • Does this answer your question? [Installing a private package from Gitlab with Yarn](https://stackoverflow.com/questions/74700110/installing-a-private-package-from-gitlab-with-yarn) – Nebulosar Jun 26 '23 at 14:47

0 Answers0