Skip to main content

Getting Started

This guide will help you set up glpkg tools for your project.

Prerequisites

  • Node.js 14.0.0 or higher
  • npm or yarn
  • GitLab account with access to package registry

Installation

Install the glpkg tools globally:

npm install -g @glpkg/installer @glpkg/publisher @glpkg/config

Or install them as dev dependencies in your project:

npm install -D @glpkg/installer @glpkg/publisher @glpkg/config

GitLab Token Setup

1. Create a Personal Access Token

  1. Go to GitLab → SettingsAccess Tokens
  2. Create a new token with the following scopes:
    • api - Full API access
    • read_registry - Read package registry
    • write_registry - Write package registry (for publishing)
  3. Copy the generated token

2. Configure the Token

You have several options to configure your token:

gitlab-config set-token YOUR_GITLAB_TOKEN

This stores the token in your user config directory (~/.config/glpkg/ or equivalent).

Option B: Using Environment Variables

Create a .env file in your project root:

GITLAB_AUTH_TOKEN=glpat-your-token-here

Option C: Per-project Configuration

Add to your .env file:

GITLAB_AUTH_TOKEN=glpat-your-token-here
GITLAB_REGISTRY=https://gitlab.com/api/v4/packages/npm/

.npmrc Configuration

glpkg tools automatically configure .npmrc when needed. However, for team projects, you might want to set up a preinstall hook:

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

This ensures .npmrc is configured before running npm install.

Verify Setup

Test your configuration:

# Check if token is configured
gitlab-config show

# Dry run a publish to verify setup
gitlab-publish --dry-run

Project Structure

A typical project using glpkg might have:

your-project/
├── .env # GitLab token (not committed)
├── .gitlab-packages.json # Registry configuration (can be committed)
├── package.json
└── src/

Next Steps