Random 401/403 from GitHub Package Registry when running npm ci or npm install from GitHub Actions

When attempting to install dependencies in GitHub Actions from GitHub Package Registry, I get random 401/403 errors.

It seems that npm install follows a certain pattern for every dependency:

  1. A request is made to https://npm.pkg.github.com/%ORGANIZATION%/dependency-name
  2. If the dependency is not on GitHub Package Registry, a request is made to https://registry.npmjs.org/dependency-name/-/dependency-name-version.tgz

That first call often fails with a 401 or 403. It seems that this is happening for different packages every time.

However, most of the requests just succeed with a 200 and I have verified (using npm whoami) that I am correctly authenticated to GitHub Package Registry.

I also tried regenerating my personal access token, but that doesn’t seem to help.

Anyone who had similar issues and found a way to solve them?

I am facing a similar issue. Yesterday I was getting 405 error always and today getting 404 Not Found. There is no issue with token am using since it was working fine till yesterday afternoon. 

I have created a help ticket and post on the API forum. So far no solution.

FYI: it seems that the issue is gone now

Edit: The issue occurs a lot less often if I keep on using the verbose options of npm install or npm ci. However, it still does occur sometimes.