Table of contents generated with markdown-toc
Github hosted NPM package. Only a template for writing NPM packages on GitHub and there's no reason to install it more than to show how to consume a privately scoped package.
Based on this guide and the official documentation:
https://levelup.gitconnected.com/private-npm-packages-in-github-package-registry-fbfda43acab3- Init a package using
npx tsdx create mylib
(TypeScript) ornpm init
. - Set .npmrc to the package scope (owner)
@thomashagstrom:registry=https://npm.pkg.github.com
- Add GitHub actions workflow using the "Publish node.js package" template or this npm-publish.yml (excluding npmjs).
- Tag, set version and push.
- Up version in
package.json
- Tag and push
- Draft a new Release from that tag
- GitHub Action builds and publishes
These details are valid if the package is private scoped.
- Open the lib where u want to consume the private NPM package
- Create a personal access token with
write:packages
scope - Config
.npmrc
to use the token (below) - Install the scoped package, e.g.
yarn add https://github.com/thomashagstrom/npm-github
Example npmrc
config for consuming thomashagstrom
org scoped packages:
@thomashagstrom:registry=https://npm.pkg.github.com/thomashagstrom
//npm.pkg.github.com/:_authToken=MyTopSecretTokenWithPackageScope