How to set up .yarnrc.yml for multiple private npm packages with different registry servers, but the same scope?

48 views Asked by At

I've seen multiple similar questions, but none gives the full answer. I'm trying to migrate my project to Yarn v4. I have several private npm packages hosted on GitLab. They have different registry server addresses, but the same scope. The previous setup with .npmrc looked like this:

@my-company:registry=https://gitlab.com/api/api-version/projects/project-id-1/packages/npm/
//gitlab.com/api/api-version/projects/project-id-1/packages/npm/:_authToken=${auth-token}

@my-company:registry=https://gitlab.com/api/api-version/projects/project-id-2/packages/npm/
//gitlab.com/api/api-version/projects/project-id-2/packages/npm/:_authToken=${auth-token}

@my-company:registry=https://gitlab.com/api/api-version/projects/project-id-3/packages/npm/
//gitlab.com/api/api-version/projects/project-id-3/packages/npm/:_authToken=${auth-token}

Where my packages have names: @my-company/package1, @my-company/package2 and @my-company/package3.

By trial and error I've found that everything works with one package @my-company/package1, when my .yarnrc.yml looks like this:

nodeLinker: node-modules

npmScopes:
  my-company:
    npmAlwaysAuth: true
    npmAuthToken: ${auth-token}
    npmRegistryServer: "https://gitlab.com/api/api-version/projects/project-id-1/packages/npm/"

yarnPath: .yarn/releases/yarn-4.1.1.cjs

But I can't find a way to set different npmRegistryServer for different packages as @my-company/package2 and @my-company/package3 require different URL. What is a proper way to config .yarnrc.yml?

0

There are 0 answers