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

Registry URL path must _exactly_ match auth token URL path #4413

Closed
Mardoxx opened this issue Sep 12, 2017 · 2 comments
Closed

Registry URL path must _exactly_ match auth token URL path #4413

Mardoxx opened this issue Sep 12, 2017 · 2 comments

Comments

@Mardoxx
Copy link

Mardoxx commented Sep 12, 2017

Yarn v1.0.1 on Win10-1703 x64, also Yarn v1.0.1 on macOS 10.12.16.

My feed is a VSTS npm feed, but I imagine this happens with other private feeds too.

  1. Create a new project with a .npmrc file in it with
registry=https://companyname.pkgs.visualstudio.com/_packaging/FeedName/npm/registry
always-auth=true
  1. Edit your local .npmrc file to have auth tokens in e.g.
; Treat this auth token like a password. Do not share it with anyone, including Microsoft support. This token expires on or before 12/11/2017.
; begin auth token
//companyname.pkgs.visualstudio.com/_packaging/FeedName/npm/registry/:_authToken=ey...
//companyname.pkgs.visualstudio.com/_packaging/FeedName/npm/:_authToken=ey...
; end auth token

N.B. trailing slash in auth token path.

  1. yarn install

  2. See 401 errors:

[1/4] Resolving packages...
verbose 1.275 Performing "GET" request to "https://companyname.pkgs.visualstudio.com/_packaging/FeedName/npm/body-parser".
verbose 1.465 Request "https://companyname.pkgs.visualstudio.com/_packaging/FeedName/npm/body-parser" finished with status code 401.
verbose 1.466 Error: Couldn't find package "body-parser" on the "npm" registry.
    at C:\Program Files (x86)\Yarn\lib\cli.js:48169:15
    at Generator.next (<anonymous>)
    at step (C:\Program Files (x86)\Yarn\lib\cli.js:92:30)
    at C:\Program Files (x86)\Yarn\lib\cli.js:103:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
error Couldn't find package "body-parser" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

A fix is to make sure that the registry path matches exactly the path of the auth token. In this instance, it just needs a trailing slash.

Interestingly, if the auth token doesn't have the trailing slash, but the registry does, this works fine. Almost as if it's a non-commutative equality!!

This works fine either way with npm install. If I had to guess, I'd say it's trimming (or adding) trailing /'s on the URL on the registry, but not the authtoken.

@BYK
Copy link
Member

BYK commented Sep 12, 2017

#4350 and #4347 should fix this. Can you try with the latest nightly to see if this is fixed already?

@Mardoxx
Copy link
Author

Mardoxx commented Sep 12, 2017

@BYK, works great, thanks!

@Mardoxx Mardoxx closed this as completed Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants