Npm install from gitlab package registry not working

I’ve published an npm package to my private group. This is the link for npm:

using npm i @coeng2020/service-fetcher i get a 404 not found message.

But when I paste the link in a broswer, I get a 304 with all the required info for npm.

Is there something Im missing from my setup?

i’ve also ran this command already in my repo: echo @coeng2020:registry= >> .npmrc

Please help

For private projects make sure you’ve also setup authentication to the registry for it to be able to resolve your project and package:

I have published the npm package to without a problem.

In another private project, I want to consume this npm package. It works locally after setting up the .npmrc with my personal access token accordingly and when executing npm install @my-org/project_a.

However, it fails when the gitlab pipeline wants to install it with the following messages:

npm ERR! code E404
62npm ERR! 404 Not Found - GET<id_of_project_a>/packages/npm/@my-org/project_a/-/@my-org/project_a-0.0.7.tgz
63npm ERR! 404 
64npm ERR! 404  '@my-org/project_a@<id_of_project_a>/packages/npm/@my-org/project_a/-/@my-org/project_a-0.0.7.tgz' is not in the npm registry.

I have set up the .npmrc in the gitlab-ci.yml as well and I have tried out several auth keys, including my personal access token and the $CI_JOB_TOKEN . I have also cleared the gitlab runner cache several times.

Accessing the url<id_of_project_a>/packages/npm/@my-org/project_a/-/@my-org/project_a-0.0.7.tgz also works via the browser.

Do you have an idea why it works locally and fails on gitlab ci cd even with the same access tokens and .npmrc ?

How can I debug this?

I got same error with a private package. How did You manage to solve It?
Thanks so much

Hi Pavel,

I managed to get it to work with a separate personal access token. Here is what i did:

  • Create a personal access token from Gitlab with the permissions read_api and read_registry.

  • Expose this personal access token in the gitlab ci pipeline through a variable

  • Ensure the .npmrc has the following content:

# Set URL for your scoped packages, e.g. package with name `@my-org/my-package` will use this URL for download.

# Add the token for the scoped packages URL. This will allow you to download.
# Make sure you replace ${GITLAB_AUTH_TOKEN} with the personal access token copied earlier or create a local environment variable (this is recommended) named GITLAB_AUTH_TOKEN with the token copied earlier as the value.

# Add token for uploading to the registry.
# NOTE: Currently, the project id is XXXXXX. If this changes, you will need to adjust this accordingly.

And then npm install should work in the gitlab as well.

I was not able to get it working with the CI_TOKEN

Awesome. That did the trick!
Thanks so much for your help