Authenticate to GitHub Packages
Install private packages from GitHub Packages with a scoped registry line and a token read from GITHUB_TOKEN in .npmrc. Token needs read:packages scope.
GitHub Packages serves npm packages from its own registry at npm.pkg.github.com. Route your organization's scope there, and authenticate with a token that has the read:packages permission.
@acme:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}npm config get @acme:registryhttps://npm.pkg.github.comOnly packages under the @acme scope go to GitHub; everything else still comes from npmjs.org. Then npm install @acme/ui works as usual once GITHUB_TOKEN is set in the environment. In GitHub Actions, the built-in secrets.GITHUB_TOKEN can do this for packages in the same organization when the workflow has packages: read. The setup is described in working with the npm registry.
A classic personal access token with read:packages is the simplest for local use. Keep it in your shell profile or a secret manager, never in the .npmrc itself.
The package scope must match the owner of the repository, in lowercase. A mismatch makes the publish fail with a permissions error.