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
- Go to GitLab → Settings → Access Tokens
- Create a new token with the following scopes:
api- Full API accessread_registry- Read package registrywrite_registry- Write package registry (for publishing)
- Copy the generated token
2. Configure the Token
You have several options to configure your token:
Option A: Using @glpkg/config (Recommended)
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
- Learn how to install packages from GitLab
- Learn how to publish packages to GitLab
- Learn about configuration management