π¦ Getting Started with Private Registry
We publish our frontend packages to a custom private registry hosted on Azure DevOps. This guide walks you through how to configure your environment and projects to authenticate and publish or install packages using Yarn, npm, or pnpm.
π 1. Authentication to the Private Registry
We use Personal Access Tokens (PAT)Β to authenticate with our private Azure registry.
You can generate a PAT at the following URL:
https://dev.azure.com/alzasoft/_usersSettings/tokensΒ
π Required Scopes
- If youβre only installing packages from the private registry, the Packaging: Read scope is sufficient.
- If you also need to publish packages from your machine, you must enable Packaging: Read & Write.
β³ Token Expiry
PATs expire after a set period β make sure to choose a reasonable expiration date when creating the token. The maximum allowed is one year, so consider setting a reminder to renew it before it expires.
π Token Format
If your token is 123, then in .yarnrc.yml:
npmAuthIdent: u:123π§Ά 2. Yarn Setup (.yarnrc.yml)
π Project-level .yarnrc.yml
Create or update .yarnrc.yml in your project root:
npmScopes:
alza: // β Named scope, must match .yarnrc.yml on the user level
npmRegistryServer: "https://alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/"
npmAlwaysAuth: trueπ User-level .yarnrc.yml
Create or update your global .yarnrc.yml:
- Windows:
C:/Users/<you>/.yarnrc.yml - macOS/Linux:
~/.yarnrc.yml
npmScopes:
alza: // β Named scope, must match .yarnrc.yml in the project
npmAuthIdent: u:<YOUR_PAT>π¦ 3. npm Setup (.npmrc)
π Project-level .npmrc
Create a .npmrc in your project:
@alza:registry=https://alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/
//alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/:always-auth=trueπ User-level .npmrc
Global .npmrc (usually at ~/.npmrc):
# NOTE: No 'u:' prefix for npm, just raw token
//alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/:_authToken=<YOUR_PAT>π 4. pnpm Setup
π Project-level .npmrc
pnpm uses .npmrc just like npm:
@alza:registry=https://alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/
//alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/:always-auth=trueπ User-level .npmrc
# Auth token for registry
//alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/:_authToken=<YOUR_PAT>π 5. Creating a Package to Publish
π Example package.json
When creating a new package, your package.json should include the following:
{
...,
"publishConfig": {
"registry": "https://alzasoft.pkgs.visualstudio.com/Alza.FE/_packaging/AlzaFE/npm/registry/"
}
}π€ 6. Steps to Publish
1. Build your package
Make sure the package is ready for publishing (e.g., built into dist folder):
npm run build2. Publish
yarn npm publish --access restricted
# or
npm publish --access restricted
# or
pnpm publish --access restrictedβ οΈ Make sure your PAT has write permissions and your
publishConfig.registryis correctly set.
β 7. Consuming a Package
Install the package like any other dependency:
yarn add @alza/button
# or
npm install @alza/button
# or
pnpm add @alza/buttonIf youβve configured the registry correctly in your .yarnrc.yml or .npmrc, it will fetch it from the private registry.
π§ͺ Troubleshooting
- 401 Unauthorized: Make sure your PAT is correct and has the required scope.
- Package not found: Confirm the package is published and the scope is correctly prefixed (
@alza/). - Authentication issues: Double-check that youβre using the correct
.yarnrc.ymlor.npmrcfiles and paths.