Publishing to Self-Managed GitLab NPM Package Registry - Error 404

Version: Gitlab Core 13.9

I’m trying to publish an npm package to Gitlab package repository. I’ve followed all the steps in the relevant doc npm packages in the Package Registry | GitLab

.npmrc

strict-ssl=false
@group-name:registry=https://gitlab.customdomain.com/api/v4/projects/347/packages/npm/
//gitlab.customdomain.com/api/v4/projects/347/packages/npm/:_authToken=XXXXXXXXX

The authToken is a GitLab Deploy Token with read_package_registry and write_package_registry permissions under the package project (ie project #347). This package is located in the “@group-name” group, such that the URL to access it is “https://gitlab.customdomain.com/group-name/package-repository

package.json

{
  "name": "@group-name/my-package",
  "version": "1.0.0",
   ...
  "publishConfig": {
    "@group-name:registry": "https://gitlab.customdomain.com/api/v4/projects/347/packages/npm/"
  },
}

Running the command npm publish returns this error after a long timeout (50 seconds or so)

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://gitlab.customdomain.com/api/v4/projects/347/packages/npm/@group-name%2my-package - 404 Not Found
npm ERR! 404 
npm ERR! 404  '@group-name/my-package@1.0.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

As far as I can tell, this configuration is identical to what’s suggested in the Gitlab docs, but it doesn’t work. Have also tried using Yarn instead of NPM and no luck.

What’s baffling is I’m able to publish a Python Pypi package to the same project with no issues whatsoever. I followed the instructions in PyPI packages in the Package Registry | GitLab . Here’s the .pypirc file I’ve used for that:

[distutils]
index-servers =
    gitlab

[gitlab]
repository = https://gitlab.customdomain.com/api/v4/projects/347/packages/pypi
username = gitlab+deploy-token-6
password = XXXXXXX

And the package shows up OK

Thoughts? Completely out of ideas here.

Have the same. Any news?

Hi. Thanks to Gitlab Support, we were able to get this resolved!

The issue actually wasn’t with GItLab at all, instead it was due to our NGINX configuration in front of it.

Basically our nginx was decoding URLs and passing them to Gitlab. However, GitLab has a built-in nginx instance, and since the urls were always decoded, it didn’t know how to process them.

The problem is illustrated here:

In our case, our fix was adding one line to our nginx config.

proxy_pass http://10.1.0.4$request_uri;

Many thanks! You made my day!