Member-only story

Consume private GitHub repository as NPM package

lockevn
2 min readJul 31, 2021

--

You write a new NPM package and it helps you earn too much money to be a billionaire. OK fine, you can keep it as private repo on GitHub, no devs can access it, … BUT, include you!

Here is the fix if you want other projects (project A) of yours can access that private repository

  • after this step, you have a token ghp_bbpO_SO_GOOD_26APth
  • in project A’s package.json, add this to dependencies

```

“billionaire”: “https://lockevn:ghp_bbp_SO_GOOD_26APth@github.com/lockevn/billionaire.git#master"

```

  • lockevn is my GitHub name
  • (optional) master is the branch I want NPM to install from billionaire

Voila, you can use your NPM directly from a repository, you even needn’t to (as I do, I’m so lazy) publish it to npmjs.com or GitHub Packages

Other notes

> You cannot delete a public package yourself (similarly, npmjs only supports to delete a public package within 72 hours)

--

--

lockevn
lockevn

Written by lockevn

Developer, Sportman. Write code with joy, bake app with heart. Opinions are my own. If you feel I save your time, go http://BuyMeACoff.ee/Lockevn

Responses (1)