Skip to main content

@glpkg/installer

A CLI tool for installing NPM packages from GitLab Package Registry.

Installation

# From npm Registry
npm install -g @glpkg/installer

# Or use directly with npx
npx @glpkg/installer [command]

Quick Start

# Configure your token (one-time setup)
gitlab-config save YOUR_GITLAB_TOKEN

# Install a package
gitlab-install add @your-org/package

Commands

add - Install GitLab Packages

Install packages from GitLab registry:

gitlab-install add <packages...> [options]

Options:

  • -D, --save-dev - Install as devDependencies
  • -g, --global - Install packages globally

Examples:

# Install specific version
gitlab-install add @your-org/package@1.0.0

# Install dev version
gitlab-install add @your-org/package@dev

# Install as devDependency
gitlab-install add @your-org/package -D

# Install globally (for CLI tools)
gitlab-install add @your-org/cli-tool -g

# Install multiple packages
gitlab-install add @your-org/pkg1 @your-org/pkg2

update - Update GitLab Packages

Update packages to their latest versions:

gitlab-install update [packages...] [options]

Options:

  • -g, --global - Update packages globally

Examples:

# Update all GitLab packages
gitlab-install update

# Update specific packages
gitlab-install update @your-org/package

# Update multiple packages
gitlab-install update @your-org/pkg1 @your-org/pkg2

# Update global packages
gitlab-install update -g

Token Configuration

The installer looks for a token in this order:

  1. Saved token via gitlab-config saveRecommended
  2. GITLAB_AUTH_TOKEN environment variable

Setup Token

gitlab-config save YOUR_GITLAB_TOKEN

Required Token Scopes

  • read_api - Read API access
  • read_registry - Read package registry

Configuration File

The tool creates .gitlab-packages.json to track configured scopes:

{
"scopes": ["@your-org", "@another-org"],
"registry": "https://gitlab.com/api/v4/packages/npm/"
}

How It Works

  1. Detects the package scope (e.g., @your-org)
  2. Temporarily configures .npmrc for GitLab registry
  3. Adds authentication token
  4. Runs npm install
  5. Restores original .npmrc

Troubleshooting

Package not found

  • Ensure the package exists in GitLab registry
  • Check your token has read_api and read_registry scopes
  • Verify the token is correctly set: gitlab-config check

Authentication errors

  • Make sure your token hasn't expired
  • Verify the token has the required permissions
  • Run gitlab-config check to verify token is configured