Publishing NPM packages to the Github Registry
Meta
I want to:
Publish an NPM package to Github package registry as it allows private packages on the free plan.
I am writing this because:
Most tutorials I found were way too long.
Data
Update your package.json
Package scope should be same as your username.
json
{
"name": "@ramitmittal/foo",
"version": "1.0.0",
}
Generate a personal access token
This token should have the write:packages
permission. New personal access token
Update your .npmrc
This .npmrc
file can either be in the same folder as the package.json
file or in the $HOME
directory.
//npm.pkg.github.com/:_authToken=${PERSONAL_ACCESS_TOKEN}
@ramitmittal:registry=https://npm.pkg.github.com
Publish
npm publish