Skip to content

Download NPM package from Github Packages #25795

Download NPM package from Github Packages #25795
Dec 10, 2021 · 1 answer

I’ve created a private repository inside an organization and successfully published a package into Github Packages (it’s available on the packages section of the repository)

However I’m unable to install the package from the command line.

I followed the documentation in order to autenticate using my personal access token (with all the necessary permissions):

$ npm login --scope=@OWNER --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS

OWNER being the organization name. This works as expected and I can login without trouble, however I get a 401 error message when using the install command (exactly the same command available in the packages section):

npm install @ORGANIZATION-NAME/REPOSITORY-NAME@1.0.0

401 Unauthorized - GET https://npm.pkg.github.com/@ORGANIZATION-NAME%2FREPOSITORY-NAME

  • Your request could not be authenticated by the GitHub Packages service.
    Please ensure your access token is valid and has the appropriate scopes configured.

If I go to that same URL in the browser and I put again my username and Personal Access Token, it allows me access to it.

I don’t understand what I’m doing wrong, any suggestions?

So in the end the problem was that I had a GITHUB_TOKEN in my .npmrc and that token it seems it has no access to install private repositories and was taking precedence over the npm login command.

Replies

1 suggested answer

So in the end the problem was that I had a GITHUB_TOKEN in my .npmrc and that token it seems it has no access to install private repositories and was taking precedence over the npm login command.

0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant