Error while installing packages using yarn or npm, `Request failed \"401 Unauthorized`

Viewed 2900

error An unexpected error occurred: "https://npm.pkg.github.com/download/[PACKAGE]: Request failed "401 Unauthorized"".

1 Answers

After doing a bit of research, I found that you have to enable/check the option of read:packages in your Github personal access token . Because some Packages require a read packages enabled.

Like: Github Personal Access Token

If you have not already setup a Github Personal Access Token, I would recommend you to follow this simple guide: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

Post that, you can either

  • create a .npmrc file at the root level of your project and export your personal access token (or)
  • run npm login with your user and token
Related