@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
| Variable | Description | Required |
|---|---|---|
GITLAB_AUTH_TOKEN | GitLab personal access token | Yes |
GITLAB_REGISTRY | Override default registry URL | No |
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
- Detects the package scope (e.g.,
@your-org) - Temporarily configures
.npmrcfor GitLab registry - Adds authentication token
- Runs
npm install - Restores original
.npmrc
Troubleshooting
Package not found
- Ensure the package exists in GitLab registry
- Check your token has
read_apiandread_registryscopes - 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
.envfile is in your project root