yarn install don't ask me for my password

Created on 25 Dec 2016  路  10Comments  路  Source: yarnpkg/yarn

What is the current behavior?

I have a private NPM registry that require user to be logged in to install package.
When i do a yarn install, i got:

error An unexpected error occurred: "http://npm.example.com/alt: unregistered users are not allowed to access package alt".

What is the expected behavior?

Yarn must ask for my password or yarn login must accept an argument to give password

Most helpful comment

Ok, looks like we figured this out. You can yarn add packages from private npm, but you should have always-auth set to true in your .npmrc.

Just run npm set always-auth true and try yarn add again

All 10 comments

Very similar to https://github.com/yarnpkg/yarn/issues/2573

Feels like yarn login should ask for a password (as npm login does).

Any progress on this? I cannot use privat repo with yarn - sadly my team should switch back to npm...
Also it does not act the same like .npmrc - since I am able to read authenticated packages by adding auth token or password to it. It would great if this issue is solved ASAP because it is serious drawback for those using private repos.

I use a private repo also at my company. I still use Yarn to manage my packages but when I publish I simply use npm publish

yes, for me as well, i cannot login with yarn with a private repo, it is not asking password.

I ran into this problem and the issue was that I was actually logged out of NPM but logged into yarn. Once I logged in to NPM iI was able to use Yarn correctly as well. Hopefully, this helps!

Ok, looks like we figured this out. You can yarn add packages from private npm, but you should have always-auth set to true in your .npmrc.

Just run npm set always-auth true and try yarn add again

This seems like a pretty major oversight in yarn login, since most private registries have read permissions that require authentication. Running a yarn or yarn add fails with 403 Forbidden because yarn login doesn't even attempt to auth.

The fact that it's being deferred until a later time when Yarn decides it thinks it needs the password is ridiculous. Just ask for the damn password and let the user decide when they need to auth. The 403 Forbidden should be enough for the user to know they need to yarn login, and to prevent them from being able to do anything that requires auth simply because yarn doesn't think you should be logged in yet is ridiculous.

@alexpyzhianov Thanks for the potential solution. Unfortunately, this doesn't seem to work in my case. It's still not asking for a password during yarn. Running a yarn add with always-auth set to true doesn't cause it to prompt for a password.

Solution described by @cbtposborne worked for me - npm login first and then yarn add will work.

Hello, @Furgas could you plz give the version you use in both npm and yarn. thanks :)

same here npm login did work

Was this page helpful?
0 / 5 - 0 ratings