DEV Community

Aashish Karki
Aashish Karki

Posted on

Managing npm and git packages.

Github has come up with their own package registry solution. similar to npm package the packages are hosted in github, I use git mostly so it makes sense for me to host packages there also provides mechanism for private packages.

Let's dive into the usage for github packages. We publish packages under a owner's scope. Say my github username is karkipy so the scope is @karkipy , and the package name will be the combination of your scope and the repo name itself such as @karkipy /randomPackage.

Now to publish this package into github registry we can specify it in the package.json file about which registry it should refer to such as

"publishConfig": {
Enter fullscreen mode Exit fullscreen mode

To publish :

npm publish
Enter fullscreen mode Exit fullscreen mode

should do the trick, now installing packages both from npm and github can be tricky as we have to specify from which we are installing packages, if only github is mentioned then the conflict will arise as many fundamental packages may not have been hosted by github package registry or if only npm is mentioned then the package from github will not be installed. So we need to specify packages to be installed from multiple organization.

Create an .npmrc for this particular configuration, make sure it is in root. Configuration for the file should be something as :




Enter fullscreen mode Exit fullscreen mode

Personal access token should be granted for the private packages that you publish in github similar to that NPM_TOKEN does the same.


Top comments (0)