GitHub has its own registry for npm packages that is available at https://npm.pkg.github.com/
This guide will explain how to login into it so that you can start installing packages from the registry.
Unlike the NPM registry which uses a password login, GitHub registry uses a Personal Access Token (PAT) as the credential.
To create the PAT, you'll have to do the following steps
- Go to Tokens under Settings
- Choose option to
Generate new token (Classic) - Enter your password
- Select the
read:packagesscope - Set expiration to
No expiration - Give a name to the token
- Click on
Generate Token - Copy the displayed token and store it for the next step
This requires a npm CLI.
npm login --registry https://npm.pkg.github.com/ --scope @newfold-labsThis command will log us in to the GitHub registry and point it to the scope that we need, i.e. @newfold-labs
Enter the requested details (replace password with token generated above) and once you're done, you should see this message.
Logged in as <github-username> to scope @newfold-labs on https://npm.pkg.github.com/.
You can now freely install packages from GitHub registry that are under @newfold-labs.
You can also set up a local user-specific
.npmrcfile to hold this token. Make sure it is not within a repo and is never committed. Once you have a token setup on your github account, add it to your local personal~/.npmrcfile (not in the repo but in your main/Users dir). It would be updated to something like this: