Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the documentation on the new .yarnrc.yml format for pro users #16156

Closed
2 of 3 tasks
thelfensdrfer opened this issue Feb 6, 2020 · 17 comments
Closed
2 of 3 tasks
Assignees

Comments

@thelfensdrfer
Copy link

Describe the bug
For yarn 2 there is a new config format, .yarnrc.yml (https://next.yarnpkg.com/configuration/yarnrc),

To Reproduce
Install yarn 2.

Expected behavior
Include what you have to insert in your config file in the docs.

Bug report checklist

  • I have filled out as much of the above information as I can
  • I have included a test case because my odds go way up that the team can fix this when I do
  • I have searched for existing issues and to the best of my knowledge this is not a duplicate
@shawnheide
Copy link

I got stuck on the scope name since it has an @ sign in it. After searching around I found out that you can just drop it from the scope name. Here is what I added to my .yarnrc.yml to get it to authenticate properly:

npmRegistries:
  //npm.fontawesome.com:
    npmAlwaysAuth: true
    npmAuthToken: "YOUR-TOKEN"

npmScopes:
  fortawesome:
    npmRegistryServer: https://npm.fontawesome.com/

@PutziSan
Copy link

Another valid configuration (.yarnrc.yml):

npmScopes:
  fortawesome:
    npmRegistryServer: "https://npm.fontawesome.com/"
    npmAlwaysAuth: true
    npmAuthToken: "YOUR-TOKEN"

@tagliala
Copy link
Member

@shawnheide @PutziSan thanks for the heads-up

Quoting from: https://next.yarnpkg.com/configuration/yarnrc

Environment variables can be accessed from setting definitions by using the ${NAME} syntax when defining the values. By default Yarn will require the variables to be present, but this can be turned off by using either ${NAME-fallback} (which will return fallback if NAME isn't set) or ${NAME:-fallback} (which will return fallback if NAME isn't set, or is an empty string).

Did anyone test with an environment variable instead of hard-coding the token in the configuration?

@seebeen
Copy link

seebeen commented Sep 15, 2021

Hello, I'm having issues with the above config. Seems the request is redirected to npmjs.org

image

@seebeen
Copy link

seebeen commented Sep 15, 2021

For posterity, npm gives the same error

image

@tagliala
Copy link
Member

tagliala commented Sep 15, 2021

Hi, there is a typo in the package name (foRtawesome-pro)

scope: @fortawesome
package name: fontawesome-pro
full: @fortawesome/fontawesome-pro

foRtawesome in the scope is not a typo 😅

PS: I've just tried

$ yarn add @fortawesome/fontawesome-pro

with the following .yarnrc.yml:

npmScopes:
  fortawesome:
    npmRegistryServer: "https://npm.fontawesome.com/"
    npmAlwaysAuth: true
    npmAuthToken: ${FONT_AWESOME_AUTH_TOKEN}

So I can confirm that yarn@berry v2.4.3 fetches the token from the environment

Without a fallback, the above configuration throws an error if the token is not found, so it will be easy to debug

@robmadole I think that is safe to add the above snippet to the instructions for Yarn 2

@seebeen
Copy link

seebeen commented Sep 19, 2021

Well, do I feel like an idiot now 😅

@tyteen4a03
Copy link

This really should be on the Docs page.

@tagliala
Copy link
Member

tagliala commented Jul 24, 2022

I can confirm

npmScopes:
  fortawesome:
    npmAlwaysAuth: true
    npmAuthToken: "${FONT_AWESOME_AUTH_TOKEN}"
    npmRegistryServer: "https://npm.fontawesome.com/"

Also works on yarn 3.2

@SaavanNanavati
Copy link

Having trouble authenticating.. where are you setting your environment variable?

yarn add @fortawesome/fontawesome-pro  
➤ YN0027: @fortawesome/fontawesome-pro@unknown can't be resolved to a satisfying range
➤ YN0041: Invalid authentication (as an unknown user)

➤ Errors happened when preparing the environment required to run this command.

@EhsanKhalili
Copy link

Hi
I use yarn v3.5.1
This is my .yarnrc.yml file:

nodeLinker: node-modules

npmScopes:
  fortawesome:
    npmAlwaysAuth: true
    npmAuthToken: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    npmRegistryServer: "https://npm.fontawesome.com/"

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

I fill npmAuthToken with my token.

but when I want to install @fortawesome/fontawesome-pro I get below error:


yarn add @fortawesome/fontawesome-pro
➤ YN0027: @fortawesome/fontawesome-pro@unknown can't be resolved to a satisfying range
➤ YN0041: Invalid authentication (as an unknown user)

➤ Errors happened when preparing the environment required to run this command.

@tagliala
Copy link
Member

Can you please try yarn config --why in the folder where you are executing yarn and check if npmScopes looks correct?

You should see something like

➤ YN0000: npmScopes                     undefined, ~/fa5pro/.yarnrc.yml   Map(1) { 'fortawesome' => Map(6) { 'npmAlwaysAuth' => true, 'npmAuthIdent' => null, 'npmAuthToken' => '********', 'npmAuditRegistry' => null, 'npmPublishRegistry' => null, 'npmRegistryServer' => 'https://npm.fontawesome.com/' } }

@EhsanKhalili
Copy link

Here is my npmScopes :

YN0000: npmScopes                     undefined, /E:/Khalili/Private/Projects/Mountain/PAK/.yarnrc.yml   Map(1) { 'fortawesome' => Map(6) { 'npmAlwaysAuth' => true, 'npmAuthIdent' => null, 'npmAuthToken' => '********', 'npmAuditRegistry' => null, 'npmPublishRegistry' => null, 'npmRegistryServer' => 'https://npm.fontawesome.com/' } }

@EhsanKhalili
Copy link

Screenshot 2023-05-14 at 2 42 13 AM image

@tagliala What is wrong with it?
Is it yarn issue or fontawesome ?

@lorenyeung
Copy link

also having the same issue, with both Yarn 3.x and trying to resolve using NPM

@IdeaHunter
Copy link

I had the same issue, yarn version 3.6.1
Leaving note for everyone who is facing similar issue and stumbled upon this ticket

for me hardcoding npmAuthToken haven't worked however somehow using environment variable worked "${FONT_AWESOME_AUTH_TOKEN}" so there is some problem with with yarn config itself

Then i decided to follow yarn instruction here and adjusted values accordingly by running following commands

yarn config set initScope npmScopes
yarn config set npmScopes.fortawesome.npmRegistryServer https://npm.fontawesome.com/
yarn config set npmScopes.fortawesome.npmAlwaysAuth true
yarn config set npmScopes.fortawesome.npmAuthToken XXXXX-XXX....

This updated yarn config similar to provided in documentation with exception of one more extra line

initScope: npmScopes

Somehow this line was critical to make it work with hardcoded token

@cozzbie
Copy link

cozzbie commented Jul 31, 2023

Had to install via npmrc before the yarn version started working. So weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests