Skip to content

[Bug?]: yarn npm login remove trailing slash #7158

Description

@rpo-fr

Self-service

  • I'd be willing to implement a fix

Describe the bug

Yarn npm login remove trailing slash during authentication, and store registry url without

To reproduce

Create a project with a local .yarnrc.yml like

npmRegistries:
  "https://<myrepo>/repository/npm-all/":
    npmAlwaysAuth: true

npmRegistryServer: "https://<myrepo>/repository/npm-all/"

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

Run yarn npm login
output:

➤ YN0000: Logging in to https://<myrepo>/repository/npm-all

√ Username: · <user>
√ Password: · ******************

➤ YN0000: Successfully logged in

You can see that trailing slash is removed on the url

If I look into ~/.yarnrc.yml, the trailing slash is not present:

npmRegistries:
  "https://<myrepo>/repository/npm-all":
    npmAuthToken: NpmToken.<token>

When i run 'yarn install --check-cache', I have messages 'Invalid authentication (as an anonymous user)'

If I had a trailing slash on registry into ~/.yarnrc.yml

npmRegistries:
  "https://<myrepo>/repository/npm-all/":
    npmAuthToken: NpmToken.<token>

and rerun 'yarn install --check-cache', I don't have error and packages are installed

yarn install --check-cache        
➤ YN0000: · Yarn 4.15.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Post-resolution validation
➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 2s 994ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 1s 148ms
➤ YN0000: · Done with warnings in 4s 203ms

Environment

System:
    OS: Windows 11 10.0.26200
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
  Binaries:
    Node: 22.17.1 - C:\Users\ROMAIN~1\AppData\Local\Temp\xfs-1d2b1fb8\node.CMD
    Yarn: 4.15.0 - C:\Users\ROMAIN~1\AppData\Local\Temp\xfs-1d2b1fb8\yarn.CMD
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions