yarn 2 (berry) doesn't use .yarnrc.yml from home directory
Asked Answered
L

1

11

I would like to use npmAuthToken from .yarnrc.yml which is located in my home directory

~/.yarnrc.yml content

npmScopes:
  company:
    npmAuthToken: NpmToken.token

~/Project/MyProject/.yarnrc.yml content

enableGlobalCache: true

logFilters:
  - code: YN0013
    level: discard

nodeLinker: node-modules

npmScopes:
  company:
    npmAlwaysAuth: true
    npmPublishRegistry: "https://company-url"
    npmRegistryServer: "https://company-url"

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
    spec: "@yarnpkg/plugin-workspace-tools"

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

However, when I try to run yarn install it fails on the resolution step with the following message: Invalid authentication (as an anonymous user). It worked fine with yarn 1 and ~/.npmrc file. Now we're going to migrate yarn 2, but I stuck with this issue. Any ideas on how to solve this? Thanks!

Less answered 9/11, 2021 at 15:28 Comment(1)
Same problem here, I can't use my private registry on GitHub after migration to Yarn 2Roanna
B
-3

You can include registry configuration directly into .yarnrn.yml file with

npmRegistryServer: "<registry_url>"
npmAlwaysAuth: true
npmAuthIdent: "<authToken>"

Also with this config is enough, you won't need adding npmScopes property anymore.

Beezer answered 16/10, 2023 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.