Publish first github package registry
Create personal access token
First, you need to create an personal access token
You will need this scope for the token
- read/write packages
- repo
Create ~/.npmrc
After that, create ~/.npmrc on your local computer (otherwise you can npm login --scope=@OWNER --registry=https://npm.pkg.github.com)
mini-classes, and snippets for every day.
The content is
//npm.pkg.github.com/:_authToken=@PERSONAL_TOKEN
Always remember your package contain a file called .npmrc also, and its content is
@OWNER:registry=https://npm.pkg.github.com
Create .npmrc in your source code
Also, every apps or source code that want to consume that package has that file too
Your package.json must follow this convention:
- name is @owner/package-name
- has a repository.url
And to consume this package. Use this:
yarn add @owner/package-name or npm install @owner/package-name
Whenever you want to publish the package, just type
npm publish
Note: credentials to publish is at ~/.npmrc (if you have token in this file, you don't need to npm login)