Search code examples
javascriptgithubnpmgithub-package-registry

Logging out of GitHub Packages for npm


I'm building a project that uses a private GitHub package. I have been using it locally with npm login --registry=https://npm.pkg.github.com which, in hindsight, was not the smartest thing as I actually need to use it in the production environment. For that I use netlify and unfortunately, it throws 401 Unauthorized whenever I try to deploy it.

Now, the problem is that I have a very hard debugging it on my local machine because, for some unknown reason, I keep being authorized despite running npm logout --registry=https://npm.pkg.github.com. Trying to run logout again I get npm ERR! Not logged in to - and yet I still can download the package.

I don't have the auth token in my .npmrc file. How comes it is still working? What can I do to go back to being unauthorized?


Solution

  • Apparently I was not logged in - just npm kept the cached version of the package. Back to square one again. If you run into the same problem, try to clean the cache or bump the package version to test it out.