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]

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

setup-registry - Setup NPM Registry

Configure .npmrc for GitLab packages:

gitlab-install setup-registry

This is typically used in a preinstall hook:

{
"scripts": {
"preinstall": "gitlab-install setup-registry"
}
}

Configuration

Environment Variables

VariableDescriptionRequired
GITLAB_AUTH_TOKENGitLab personal access tokenYes
GITLAB_REGISTRYOverride default registry URLNo

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

Authentication errors

  • Make sure your token hasn't expired
  • Verify the token has the required permissions
  • Check that the .env file is in your project root