This question is related to these. But none of the solutions worked for me.
I am adding an answer here because after a day of trying different variations of the solutions here and elsewhere, I found that my issue was something else.
My issue was that, while npm
is not case sensitive with regards to package names, yarn
is when it comes to authentication!
You need only to use .npmrc in the root of your project with this content:
//npm.pkg.github.com/:_authToken=GITHUB_PERSONAL_TOKEN
@OWNER:registry=https://npm.pkg.github.com
Keep in mind that GITHUB_PERSONAL_TOKEN needs read:packages scope permissions in order to read the packages from your private repo.
The following worked for me in .npmrc
@mvce-superstars:registry=https://npm.pkg.github.com
Using yarn v2, the following worked for me in .yarnrc.yml
:
npmScopes:
"mvce-superstars":
npmAlwaysAuth: true
npmRegistryServer: "https://npm.pkg.github.com"
Firstly, note the lowercase scope name. This is supposed to be the name of the owner of the repository (MVCE-Superstars) where the package was published, but the name has to be all lower-cased.
.npmrc
OR .yarnrc.yml
file into the repoository.npm login --registry=https://npm.pkg.github.com/
OR yarn npm login --scope=mvce-superstars
commandread:package
, write:package
, and repo
)npm publish
OR yarn npm publish
npm notice
npm notice