Private NPM package registry cannot be accessed across two projects

Hello everyone, I was wondering if someone could help me with my CI/CD configuration for a multi-JS project setup.

Project “js-core” has some core JS libaries, and project “vue-core” has some reusable vue components. They are both published as npm packages to the “js-core” project’s repository (so that we can use a deploy token with npm publish, as opposed to using a group deploy token, where you have to publish directly to the API). “vue-core” has a dependency of “js-core”, so it needs to access the npm package registry of the “js-core” project to download it inside of the Docker CI/CD instance.

However, gitlab does not allow me to override the package registry’s URL. According to some google research, setting the values with yarn config set @myorg:registry <gitlab-url> / yarn config set //gitlab.com/api/v4/... <deploy token> or npm config set @myorg:registry <gitlab-url> / npm config set //gitlab.com/api/v4/... <deploy token> should work. However I can see that it is still trying to download the packages from the “vue-core” package registry, even though it is disabled as a feature there.

This is the part of my .gitlab-ci.yml that runs before it fails:

image: node:17-alpine
stages:
  - build
  - test
before_script:
  - yarn config set @myorg:registry https://gitlab.com/api/v4/projects/${NPM_PACKAGES_PROJECT_ID}/packages/npm/
  - yarn config set //gitlab.com/api/v4/projects/${NPM_PACKAGES_PROJECT_ID}/packages/npm/:_authToken ${NPM_PACKAGES_PROJECT_TOKEN}
  - yarn install

It fails at “yarn install” with:

[2/4] Fetching packages...
error An unexpected error occurred: "https://gitlab.com/api/v4/projects/<vue-core_project_id>/packages/npm/@myorg/js-core/-/@myorg/js-core-1.0.0.tgz: Request failed \"404 Not Found\"".

Where the project ID should be the value of <js-core_project_id>

I have tried writing to all possible .npmrc files, setting the values with npm config set and yarn config set, deactivating the “packages” feature

I am out of ideas, any help is appreciated!

2 Likes

Hi, @bnunamak. I’ve encountered the same issue. Did you solve your issue by any chance?

1 Like

Hello

same error
npm i works correctly, but I need yarn cause there are other modules which use it

any luck?
I tried npmrc / yarnrc / change yarn version / change node version / with/without always-auth / change global registry