I amm facing an issue while trying to download a package from the GitHub npm registry. Whenever I attempt to install any package using the npm registry URL (https://npm.pkg.github.com/download/[PACKAGE]), I encounter a '401 Unauthorized' error.
The exact error message I am receiving is:
error
>An unexpected error occurred: \
https://npm.pkg.github.com/download/[PACKAGE]: Request failed \"401 Unauthorized\".
I have already logged into npm registry on the cli
npm login --registry=https://npm.pkg.github.com
I have already made sure that my GitHub credentials are correctly configured, and I am logged in to GitHub via the npm CLI using the npm login command. Despite this, I still can't seem to access the package.
Any insights, troubleshooting tips, or solutions to resolve this '401 Unauthorized' error would be greatly appreciated.
Thank you for your help!
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
.npmrc
file at the root level of your project and export your personal access token (or)npm login
with your user and token