Article Image
read

As I'm working with Node.js I have a few modules what I'd like to share between different applications. Let's say I have a module with a few common middlewares for Express which I want to reuese time to time. npm is a great tool to resolve dependencies but what if my apps and modules are private? If you have many private repos you can consider to setup your own npm registry, but it's seems a bit overkill for me so I decided to figure out a simpler way.

Luckily npm supports URLs as dependencies and GitHub have a nice API. With the previous two facts we will be able to resolve private dependencies.

First we need to create a GitHub API token (help available here). As soon as we have a valid token we can use GitHub API's get archive link method to get our private repo.

So we can add private repos as dependencies to our package.json in the following format:

"dependencies": {
  "foo": "https://api.github.com/repos/johndoe/foorepo/tarball/master?access_token=xyz"
}
Blog Logo

Kalman Speier


Published

Image

Kalman Speier

Logbook of my journey in software development.

Back to Overview