This question is related to these. But none of the solutions worked for me.
- Yarn can't find private Github npm registry
- Installing private package from Github Package registry fails with not found/not authorized
I can install a package without issues with npm install @scope/package
however I cannot do the same with yarn: yarn add @scope/package
yarn throws the following error:
An unexpected error occurred: "https://npm.pkg.github.com/download/@scope/package/1.2.8/089b08cffb16074c210ec3a59b04de268ae1c7b3a0492dce110adee3ada05bdd: Request failed \"401 Unauthorized\"".
my .npmrc file looks like this: (tried with and without below .yarnrc)
registry=https://registry.npmjs.org/
//npm.pkg.github.com/:_authToken=MY_AUTHTOKEN
@scope:registry=https://npm.pkg.github.com/
I have tried adding this .yarnrc file:
registry "https://registry.npmjs.org"
"@scope:registry" "https://npm.pkg.github.com"
(without .yarnrc) I've tried this .npmrc file
registry=https://registry.yarnpkg.com/
@scope:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=MY_AUTHTOKEN
always-auth=true
Where MY_AUTHTOKEN
is my Personal Access Token
I've generated from Github. (it has access to everything in packages)
I have tried to:
- remove yarn.lock
- remove .yarnrc
- login with
npm login
using my PAT as the password - logout of npm and removing global .npmrc and .yarnrc
- logging in with
yarn login
In case of any confusion I'm not actually trying @scope and /package but my actual scope and package name.
I do have access to the scope and package on Github.
and again my first setup works just fine with npm. But I cannot get this working with yarn, and cannot find any valid existing solution on SO.