use-my-ghp-lib
This is a Next.js project bootstrapped with create-next-app
.
Goal
test project to use the @erkobridee/my-ghp-lib from the GitHub Packages
Project setup
npx create-next-app use-my-ghp-lib --use-npm
cd use-my-ghp-lib
npm i -D @types/react @types/react-dom @types/node typescript
touch tsconfig.json
next dev
Configuring npm for use with GitHub Packages
TODO: create a GITHUB_PAT with the access to only read packages
There are 2 possible ways to access and use packages from the GitHub packages
.npmrc
useful to use on CI/CD pipelines
//npm.pkg.github.com/:_authToken=${GITHUB_PAT}
@erkobridee:registry=https://npm.pkg.github.com/
login into the GitHub Packages
recommended on the developer machine, this will add the access to the global .npmrc file
$ npm login --scope=@erkobridee --registry=https://npm.pkg.github.com
> Username: USERNAME
> Password: GITHUB_PAT
> Email: PUBLIC-EMAIL-ADDRESS
$ echo "@erkobridee:registry=https://npm.pkg.github.com/" >> ~/.npmrc
CLI commands
- development:
npm start
- ( http://localhost:3000 )
Documentation
Useful reference
-
Private NPM Packages with GitHub Actions & Packages | Brian Morrison II
-
Github Actions with private package (Github Package Registry or NPM) | charliejwalter.net - 2020/03/31
-
Deploying a Next.js app to GitHub Pages - DEV Community 👩💻👨💻 - 2020/02/26
-
Going Truly Serverless with Next.js Static Site Generation - 2021/02/20
GitHub Action know issue
if you're consuming a GitHub package from a different account or from a GitHub organization, you'll need to have a GitHub Personal Access Token from there with the rights to read GitHub Packages