Consuming node packages from the GitHub registry service

Recently I was using GitHub, and I noticed at the top of the page a new button/number combo, used by.



So, that was interesting - it's showing how many repositories are using a particular node package.

Today, I was scrolling through by Twitter feed and I saw a JavaScript develop posting that he's using the GitHub package registry service for his packages moving forward, and not so much the npm registry service.

That GitHub had a registry service was news to be, so I was curious to see how one would use packages stored there rather than on npm.

It's worth pointing out, that this service currently seems to be in the beta phase, but here is the page that describes the new offering: https://github.com/features/package-registry.

Within GitHub itself, if you navigate to an Organisation or User profile, you will spot a new tab "Packages".








A simple search on GitHub reveals there are currently 125 npm packages on the GitHub registry service. So, how do we actually use this package registry in our environment when pulling packages.

For this example, I will focus on the package with the most downloads - i18next-axios-backend.

The relevant section in the documentation that describes how to use the GitHub registry service: https://help.github.com/en/articles/configuring-npm-for-use-with-github-package-registry#installing-a-package

So, basically in your project folder you will want to have a file names .npmrc in the project root.

Because the particular package falls under the GitHub user providenceinnovation, the contents of the file should contain the following:

@providenceinnovation:registry=https://npm.pkg.github.com/

You also need to authenticate yourself. You can do this with the npm login command on your system, or specifying a personal access token in a ~/.npmrc file:

//npm.pkg.github.com/:_authToken=PERSONAL-ACCESS-TOKEN

For now, we can just do the manual login process:

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


(You need to scope the login the owner of the package you want to pull)

Then, package reference is the username/package name, prefixed with an @ symbol. For example:

npm install @providenceinnovation/i18next-axios-backend

Or in your package.json, within the dependencies, specify

"@providenceinnovation/i18next-axios-backend": "1.0.2"

and run

npm install.


Popular posts from this blog

Report row buttons firing a dynamic action

Accessing the last request value from a page submission

Installing Oracle Instant Client on Ubuntu