Npm install from private project registry returning E404

Hi,

I succeeded in installing an NPM package into a private project on my Gitlab instance.

The package.json

{
  "name": "my-package",

.npmrc

registry=https://my-gitlab-instance.com/api/v4/projects/395/packages/npm/
//my-gitlab-instance.com/api/v4/projects/395/packages/npm/:_authToken="${NPM_TOKEN}"

I published the package

NPM_TOKEN="<secret>" npm publish

Now at the package registry page of project 395 (https://my-gitlab-instance.com/eng/family-test/tools/my-package/-/packages/) I can see the project and the assets tgz.

Then, I’m trying to install a package from another nodejs project using

npm config set -- //https://my-gitlab-instance.com/:_authToken=<secret>
npm config set -- //https://my-gitlab-instance.com/api/v4/projects/395/packages/npm/:_authToken=<secret>
npm config set registry=https://my-gitlab-instance.com/api/v4/projects/395/packages/npm/
npm install my-package

But I’m getting the error

npm ERR! code E404
npm ERR! 404 Not Found - GET https://my-gitlab-instance.com/api/v4/projects/395/packages/npm/my-package
npm ERR! 404
npm ERR! 404  'my-package@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Local\npm-cache\_logs\2023-04-17T13_03_21_538Z-debug-0.log

However, with my browser, I opened the link (https://my-gitlab-instance.com/api/v4/projects/395/packages/npm/my-package) and I got a valid JSON file. I also followed the tarball link and was able to download the file with no problem.

I tried different token configurations but every time I’m getting the same error

  • Personal access token with all the scope, or sudo, or only read/write registry or just api.
  • Project token with all the scope, or only read/write registry or just api. With a developer role or higher.

What’s wrong?

I read the documentation several times (https://docs.gitlab.com/ee/user/packages/npm_registry/#install-from-the-project-level)

Information on my setup

Gitlab version: CE 15.9
OS: Windows 10
NPM: 9.5.0

I’m not sure is the topic actual, but probably the issue with

npm config set -- //https://my-gitlab-instance.com/:_authToken=<secret>

just remove https://

npm config set -- //my-gitlab-instance.com/:_authToken=<secret>