I’ve just run into a similar situation. It seemed that yarn was only looking in the main Yarn package registry for my organization’s private package. I had copied the examples from GitHub’s Packages documentation for constructing your .npmrc file directly to the .yarnrc file in the project that will be consuming the app, not knowing that the formats were different (I’ve never had to deal with .yarnrc files before).
However, after updating the .yarnrc file with the correct format that you’ve mentioned above (which I also found in googling around), yarn successfully found the private package and installed it correctly.
As a heads up, my yarn version: 1.17.3
Steps I Took
- Start new terminal session
cdto the projectnvm use(if you have a specific node version to use)- Add the correctly-formatted
.yarnrcfile to the project. See below for what it looks like. - Manually add the package and version range to the
package.jsonfor my private package - Run
npm login --registry=https://npm.pkg.github.com --scope=@MyOrg- See the note below on scope / org gotcha’s
- Run
yarn
That worked for me.
.yarnrc
"@myorg:registry" "https://npm.pkg.github.com"
Note: See below for a note on the org / scope name gotcha’s
Other Notes
I know that it appears that you don’t have any issues with this, given your GH username / scope above, but for anyone else that comes here, the documentation on GH is a little sparse with regards to mapping your username / org name to a scope in the package name. Just remember these little gotcha’s here:
- The name of your package must always be scoped to your org (or username)
- E.g.,
name: @johndturn/my-package
- E.g.,
- If your organization has capital letters in it, like
MyOrg, just replace them in the name of the package in yourpackage.jsonand your.yarnrcwith lowercase- E.g.,
name: @myorg/my-package - Note: When authenticating with
npm login, I still have kept the uppercase letters in the--scope=argument.
- E.g.,
- The name of your package doesn’t have to be the same name of the repo.
- E.g., for a repo called
MyOrg/random-prefix.js-lib, you can havename: @myorg/js-libin yourpackage.jsonfile for the project itself. Then, installing it in other projects will look something like@myorg/js-lib: 1.0.0.
- E.g., for a repo called