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

Yarn login does not ask for password and does not login #6405

Open
SleeplessByte opened this issue Sep 19, 2018 · 9 comments
Open

Yarn login does not ask for password and does not login #6405

SleeplessByte opened this issue Sep 19, 2018 · 9 comments
Assignees
Labels

Comments

@SleeplessByte
Copy link

What is the current behavior?

$ yarn logout
yarn logout v1.9.4
success Cleared login credentials

$ yarn login
yarn login v1.9.4
question npm username: foobar
question npm email: email@domain.tld
Done in 6.35s.

$ yarn publish
[... prepublish output ...]
Done in 8.89s.
error Couldn't publish package: "https://registry.yarnpkg.com/packagename: You must be logged in to publish packages."

What is the expected behavior?

$ yarn login
yarn login v1.9.4
question npm username: foobar
question npm email: email@domain.tld
question npm password: *****
question otp: 123456
Done in 6.35s.

$ yarn publish
[... prepublish output ...]
Done in 8.89s.

Please mention your node.js, yarn and operating system version.
node: v10.7.0
yarn: 1.9.4
system: windows 10

@ghost ghost assigned arcanis Sep 19, 2018
@ghost ghost added the triaged label Sep 19, 2018
@dudekaa
Copy link

dudekaa commented Oct 19, 2018

Same bug when installing scoped packages.
Probably somehow related to #5216 and #4451.

$ yarn init

$ yarn login
yarn login v1.10.1
warning package.json: License should be a valid SPDX license expression
info npm username: ...
info npm email: ...
Done in 0.04s.

$ yarn --verbose add @nangu/hbbtv
yarn add v1.10.1
warning package.json: License should be a valid SPDX license expression
verbose 0.192 Checking for configuration file "/home/nost/projekty/bugs/rdm-408/.npmrc".
verbose 0.193 Checking for configuration file "/home/nost/.npmrc".
verbose 0.193 Checking for configuration file "/usr/etc/npmrc".
verbose 0.193 Checking for configuration file "/home/nost/projekty/bugs/rdm-408/.npmrc".
verbose 0.194 Checking for configuration file "/home/nost/projekty/bugs/.npmrc".
verbose 0.194 Checking for configuration file "/home/nost/projekty/.npmrc".
verbose 0.194 Checking for configuration file "/home/nost/.npmrc".
verbose 0.194 Checking for configuration file "/home/.npmrc".
verbose 0.195 Checking for configuration file "/home/nost/projekty/bugs/rdm-408/.yarnrc".
verbose 0.195 Found configuration file "/home/nost/projekty/bugs/rdm-408/.yarnrc".
verbose 0.195 Checking for configuration file "/home/nost/.yarnrc".
verbose 0.196 Found configuration file "/home/nost/.yarnrc".
verbose 0.196 Checking for configuration file "/usr/etc/yarnrc".
verbose 0.196 Checking for configuration file "/home/nost/projekty/bugs/rdm-408/.yarnrc".
verbose 0.196 Found configuration file "/home/nost/projekty/bugs/rdm-408/.yarnrc".
verbose 0.196 Checking for configuration file "/home/nost/projekty/bugs/.yarnrc".
verbose 0.196 Checking for configuration file "/home/nost/projekty/.yarnrc".
verbose 0.196 Checking for configuration file "/home/nost/.yarnrc".
verbose 0.197 Found configuration file "/home/nost/.yarnrc".
verbose 0.197 Checking for configuration file "/home/.yarnrc".
verbose 0.199 current time: 2018-10-19T08:34:17.451Z
info No lockfile found.
warning test@1.0.0: License should be a valid SPDX license expression
[1/4] Resolving packages...
verbose 0.292 Performing "GET" request to "https://registry.npmjs.org/@nangu%2fhbbtv".
verbose 2.093 Request "https://registry.npmjs.org/@nangu%2fhbbtv" finished with status code 404.
verbose 2.094 Error: https://registry.npmjs.org/@nangu%2fhbbtv: Not found
    at Request.params.callback [as _callback] (/usr/share/yarn/lib/cli.js:61073:18)
    at Request.self.callback (/usr/share/yarn/lib/cli.js:120166:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/usr/share/yarn/lib/cli.js:121138:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/usr/share/yarn/lib/cli.js:121060:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
error An unexpected error occurred: "https://registry.npmjs.org/@nangu%2fhbbtv: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/home/nost/projekty/bugs/rdm-408/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
$ cat .yarnrc 
registry "https://registry.npmjs.org/"
$ cat yarn-error.log 
Arguments: 
  /usr/bin/node /usr/share/yarn/bin/yarn.js --verbose add @nangu/hbbtv

PATH: 
  /home/nost/.rvm/gems/ruby-2.4.0/bin:/home/nost/.rvm/gems/ruby-2.4.0@global/bin:/home/nost/.rvm/rubies/ruby-2.4.0/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/nost/projekty/merge3po:/home/nost/.rvm/bin:/home/nost/WebStorm/bin:/home/nost/.local/bin:/home/nost/bin:/home/nost/projekty/merge3po:/home/nost/.rvm/bin:/home/nost/WebStorm/bin:/home/nost/.local/bin:/home/nost/bin

Yarn version: 
  1.10.1

Node version: 
  8.12.0

Platform: 
  linux x64

Trace: 
  Error: https://registry.npmjs.org/@nangu%2fhbbtv: Not found
      at Request.params.callback [as _callback] (/usr/share/yarn/lib/cli.js:61073:18)
      at Request.self.callback (/usr/share/yarn/lib/cli.js:120166:22)
      at emitTwo (events.js:126:13)
      at Request.emit (events.js:214:7)
      at Request.<anonymous> (/usr/share/yarn/lib/cli.js:121138:10)
      at emitOne (events.js:116:13)
      at Request.emit (events.js:211:7)
      at IncomingMessage.<anonymous> (/usr/share/yarn/lib/cli.js:121060:12)
      at Object.onceWrapper (events.js:313:30)
      at emitNone (events.js:111:20)

npm manifest: 
  {
    "name": "test",
    "version": "1.0.0",
    "description": "Test repo for installation of scoped package",
    "main": "index.js",
    "license": "PUBLIC",
    "dependencies": {
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile

Workaround
Use npm login instead of yarn login, then yarn will use this token when registry URL matches.

@Nighthawk22
Copy link

Workaround sadly does not work for us. We needed to change to npm again 😢

@Bec-k
Copy link

Bec-k commented Jun 30, 2020

same here

@mdeknowis
Copy link

yarn loginis not working. YOu have to use npm login instead. It looks like, yarn is not capable to create auth tokens!

You can check by using yarn config list you should have an auth token for you registry

@psteinroe
Copy link

Same issue here! npm login and then using yarn works though.

@Eliav2
Copy link

Eliav2 commented Nov 15, 2021

any update?? very surprised by this behavior. yarn login --registry <registry> does not work

@slhck
Copy link

slhck commented Nov 24, 2021

Simple solution: Make sure that your global ~/.npmrc does not contain an auth token for registry.npmjs.org. If it is there, remove it, and login again.

Longer answer:

This is so fundamentally broken. I ran into this on a new machine, and I did log into my private registry using npm login --registry …. The .npmrc file in the project says:

always-auth=true
@xxx:registry=https://npmregistry.example.com

But still, when I ran yarn install in the project, I got:

error An unexpected error occurred: "https://npmregistry.example.com/@xxx%2fxxx/-/xxx-0.1.1.tgz: Request failed \"401 Unauthorized\"".

Yarn wasn't even trying to log in. The problem was apparently that my global ~/.npmrc config file had the wrong auth token stored:

$ npm config list
; "user" config from /Users/werner/.npmrc

//registry.npmjs.org/:_authToken = (protected)
; always-auth = true ; overridden by project

; "project" config from /xxx/xxx/.npmrc

@xxx:registry = "https://npmregistry.example.com"
always-auth = true

; node bin location = /Users/werner/.nvm/versions/node/v16.13.0/bin/node
; cwd = /xxx/xxx
; HOME = /Users/werner
; Run `npm config ls -l` to show all defaults.

See the registry.npmjs.org in there? This needs to be removed. Edit ~/.npmrc and remove the line with the auth token. Now login again into your private registry:

npm login --registry https://npmregistry.example.com

Now yarn will pick up the correct token when you run yarn install.

@kaedwen
Copy link

kaedwen commented Feb 17, 2022

I don't know whats going on here ... This is a fundamental feature and I do not want to use npm at all. This feature is broken for years. Is it wanted that yarn dies? People are forced to use npm because this, is that the intention?

@parkerault
Copy link

Sorry for the necro-post, but I recently upgraded a monorepo from yarn 1 to yarn 3, and our restricted organization packages started returning 404 on yarn install. Yarn 1.x would read the npm auth token from .npmrc, but yarn >=2.x will only use .yarnrc.yml. You can run yarn npm login to cache the auth token, or you can manually edit your ~/.yarnrc.yml file with your auth token from ~/.npmrc:

npmRegistries:
  "https://registry.yarnpkg.com":
    npmAuthToken: npm_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Note that config declarations from hierarchical yarnrc files are not merged, so if you have npmRegistries in your project's yarnrc.yml, it will overwrite the settings from your user yarnrc.yml.

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

No branches or pull requests