How to download and install packages from (private) artifactory and yarn v4?

278 views Asked by At

In our project we are currently using yarn v1. We are able to download packages from our private registry (artifactory). Our packages are scoped packages, which means our package.json looks like this:

 ...
 "dependencies": {
    "@mui/icons-material": "^5.9.1",
    "@private/lib1": "1.2.2",
    "@private/lib2": "1.0.2",
 ...

With yarn v1 everything works fine. Now we want to upgrade to yarn v4. We migrated .npmrc to .yarnrc.yml

npmScopes:
  private:
    npmAlwaysAuth: true
    npmRegistryServer: "https://artifactory.company.com/artifactory/api/npm/private-npmjs/"
    npmAuthToken: MY_TOKEN

and also set yarn version to berry. So far so good. But the first time we run

yarn install

yarn failed with the following error:

➤ YN0001: │ Error: @private/lib1@npm:1.2.2: @private/lib1@npm:1.2.2::__archiveUrl=https%3A%2F%2Fartifactory.company.com%3A443%2Fartifactory%2Fapi%2Fnpm%2Fprivate-npmjs%2F%40private%2Flib1%2F-%2F%40private%2Flib1-1.2.2.tgz%23 isn't supported by any available resolver

When we remove our own (private) dependencies

 "dependencies": {
    "@mui/icons-material": "^5.9.1",
 ...

and run yarn install again, yarn is downloading all packages without any error. After the first run of yarn install we can now add our dependencies again:

 ...
 "dependencies": {
    "@mui/icons-material": "^5.9.1",
    "@private/lib1": "1.2.2",
    "@private/lib2": "1.0.2",
 ...

and re-run yarn install. NOW the packages from our private registry are downloaded and installed as well. There are no errors.

It seems, that only the first time we run yarn install there is a problem with installing packages from our registry. The problem is, that this also happens in our gitlab pipelines, which means, we are currently unable to build our app with yarn v4.

So the only problem we have with yarn v4 is that the first run of yarn install fails. My question is, what can we do to build our apps (and libs) with yarn v4? This happens with all our apps and libs - so it's not just an issue with this app. Is there a command we have to run before yarn install (the first time)?

0

There are 0 answers