NPM instance level registry - publish and install not possible

Hi Folks!

we have upgraded to the gitlab-ee 14.1.3 from 12.5 to use the NPM registry.
But i have a issue with the instance level package registry

Publishing my package to a project is working fine.
Installing with the scope:registry set to the project-url is also working fine.
But i do not want to search for the project-id everytime i want to use a npm module and set the registry for it.

So here come’s the part that doesn’t work:
I want to set the registry to the instance level:
https://onpremise.gitlab.installation/api/v4/packages/npm/

This does not work - npm install gives the following error:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@scope/module - Not found
npm ERR! 404
npm ERR! 404 ‘@scope/module@*’ is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

This drives me crazy.
It should work according to the documentation - also as this is given as the registry in the package detail. I have searched the topics in the forum, even watched how to videos on YT.

Is there something i have missed?

Current setup on my client:

  • Module publishConfig is set to the project repository (publish works fine)
  • Published via personal access token
  • Set the registry to instance-level url
  • Auth token for instance level + project level set in global .npmrc

When i try to call the instance level npm package url:
https://onpremise.gitlab.installation/api/v4/packages/npm/
i get a {“error”:“404 Not Found”}

When i publish the module with the instance level url i get a 404 with the error message, that the module could not be found in the registry. As this module is new, it can’t be in the registry. Which brings me to belief that something isn’t working right with the instance level npm registry or it is me :smiley:

Any ideas how to solve this?

Thanks alot!

BR
Pascal

1 Like

Hi @coffeejunky ,

Did you solved the issue?
I have the same problem trying to publish to instance level.
We are using gitlab SaaS (14.8-pre).

BR
Valery

Hi Valery,

so sorry for the late response!

As per Documentation, the publish to the instance level is not possible.
So the publish configuration does target the project level registry.

Unfortunately, i did some errors with the .npmrc file.
I have deleted all .npmrc files out of the repositories and i only have the one in my ~/ folder left.

It contains the following content:

@namespace:registry=https://onpremise.gitlab.de/api/v4/packages/npm/
//onpremise.gitlab.de/api/v4/packages/npm/:_authToken=<Token>

With that, i am able to pull any module without the need to include the project level packages-url in my .npmrc.

The user only needs the corresponding authorization for the project to pull.
We have created a seperate gitlab group for the npm module development, so this works for us in our team.

BR
Pascal

I just found the solution for both npm and yarn

Place these codes inside of your global .npmrc in ~/.npmrc, then change the scope and URL to yours.

@yourscope:registry=https://gitlab.example.com/api/v4/packages/npm/

//gitlab.example.com/api/v4/packages/npm/:_authToken=<your_access_token>
//gitlab.example.com/api/v4/projects/:_authToken=<your_access_token>  # This line solved my problem

Read more about troubleshooting

1 Like

As per Documentation, the publish to the instance level is not possible.

This is quite confusing… I assume it means that to publish you have to use the project level method? (while installing work with the instance level)
Maybe it’s obvious, but a hint in the documentation would have helped. (a bit annoying to have to juggle different variants of the npmrc files)

You have to publish it by using project id that’s sort of given everywhere but for installing, many of us got stuck I have faced similar issue and found a standard solution according to the documentation.
Need to follow three simple steps to install using instance level:

  1. Authenticate to the Package Registry
    npm config set – //your_domain_name/api/v4/packages/npm/:_authToken=your_token

  2. Set the registry
    npm config set @scope:registry https://your_domain_name.com/api/v4/packages/npm/

  3. Install the package
    npm install @scope/my-package

This way you don’t need to create .npmrc file in your project where you want to use of package

Can you explain more about this line in your post: “I have deleted all .npmrc files out of the repositories and i only have the one in my ~/ folder left.”
We have group with 8 projects, few of this projects have .npmrx files. We able to publish our packages from 3 projects, but not able to call them from one of the project - we get 404 error - package not found. Was hopping that using your suggestion with delete all .npmrc files will help us. But can’t figure where is only one file stay.

This worked for me as well! Thank you!

I’m using yarn. This doesn’t work for me. I get this error:

error An unexpected error occurred: "https://gitlab.com/api/v4/packages/npm/@group-name%2fcore: Not found".

My package is @group-name/core in this example and in gitlab my project name is core inside a group named group-name.