Member-only story
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
- Assume that your NPM package is built from github.com/lockevn/billionaire.git to https://github.com/lockevn/billionaire/tree/master/dist folder (commit that /dist to repo as well)
- Go to https://github.com/settings/tokens
- Generate new personal access tokens, remember to allow the repo scopes
- 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
- I use this approach on Heroku
- My lib can be consume from API projectA (NodeJS) and Front-end projectB (VueJS)
- If you want to publish npm package to GitHub Packages, see https://windix.medium.com/host-and-publish-npm-package-on-github-bb419a2acfd3
> You cannot delete a public package yourself (similarly, npmjs only supports to delete a public package within 72 hours)