NPM Private Packages

1. Overview

This project uses NPM packages published to a private GitHub Packages registry. Special configuration is required for authentication.

2. GitHub Personal Access Token (PAT)

Create a Personal Access Token to authenticate with the private registry.

2.1. Creating the Token

  1. Log in to your GitHub account

  2. Navigate to Settings > Developer settings > Personal Access Tokens > Tokens (classic)

  3. Generate a new token with the following permissions:

    • read:packages - Install packages

    • repo - Access private repositories

  4. Copy and securely store the token

The token is only displayed once. Store it securely immediately after creation.

3. Authentication Configuration

Configure npm to authenticate with GitHub Packages using one of the following methods.

3.1. Global Configuration

Apply settings to all projects on your machine:

npm config set @christhonie:registry https://npm.pkg.github.com
npm config set //npm.pkg.github.com/:_authToken <PAT>

3.2. Project-Specific Configuration

The project includes an .npmrc file with the following content:

@christhonie:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_AUTH_TOKEN}

Set the NPM_AUTH_TOKEN environment variable before running npm install or npm update.

3.3. Setting the Environment Variable

Linux/macOS

Add to your shell configuration (~/.bashrc or ~/.zshrc):

export NPM_AUTH_TOKEN=<PAT>

Reload your shell configuration.

Windows Command Prompt (Persistent)
setx NPM_AUTH_TOKEN <PAT>
setx sets the variable for new terminal sessions only. Open a new terminal to see the change.
Windows Command Prompt (Current Session)
set NPM_AUTH_TOKEN=<PAT>
Windows PowerShell

Add to your PowerShell profile:

$env:NPM_AUTH_TOKEN = "<PAT>"

4. Verifying Configuration

Test the configuration by running:

npm install

If authentication is successful, private packages from @christhonie scope will install correctly.