lpm setup
Configure .npmrc authentication or print GitHub Actions and GitLab CI workflows.
Use lpm setup to configure registry access or create a starting workflow for CI secrets.
lpm setup ci npmrc [-r <URL>] [--oidc]
lpm setup ci github-actions [--env <NAME>]
lpm setup ci gitlab [--env <NAME>]
lpm setup local [-d <DAYS>]Choose a command for the client or workflow that needs authentication:
lpm setup ci npmrc # create .npmrc for npm, pnpm, or Yarn in CI
lpm setup local # create a local read-only project token
lpm setup ci github-actions # print a GitHub Actions OIDC workflow fragment
lpm setup ci gitlab # print a GitLab CI OIDC workflow fragmentChoose a setup mode
| Command | Result | Use it when |
|---|---|---|
lpm setup ci npmrc | Writes a project .npmrc with a literal token | npm, pnpm, Yarn, or another npm-compatible client runs in CI |
lpm setup local | Writes a project .npmrc with a new read-only token | An npm-compatible client needs local access to private @lpm.dev/* packages |
lpm setup ci github-actions | Prints an OIDC workflow fragment and an authorization command | GitHub Actions must pull project secrets with lpm env |
lpm setup ci gitlab | Prints an OIDC job fragment and an authorization command | GitLab.com CI must pull project secrets with lpm env |
If CI uses only LPM CLI, set LPM_TOKEN on the package command. LPM CLI does not need a generated .npmrc file.
- name: Install private packages
run: lpm ci
env:
LPM_TOKEN: ${{ secrets.LPM_TOKEN }}Project configuration in lpm.json
The GitHub Actions and GitLab targets prepare OIDC workflows for lpm env pull.
These workflows use the vault field in lpm.json. The generated deploy step also runs the deploy script from this file.
{
"vault": "7f3a1e2c-5b9d-4a8f-b6c1-9b1d2e3f4a5b",
"scripts": {
"deploy": "./deploy.sh"
}
}Create the local secret project before you generate the workflow:
lpm env set API_URL=https://api.example.com
lpm env push
lpm setup ci github-actions --env productionThe lpm env commands create the vault field. Commit lpm.json after this field exists.
The GitHub Actions target copies the vault ID into the printed LPM_VAULT_ID value. If the field is missing, it prints <your-vault-id>.
The GitLab job can read the vault ID from the checked-out lpm.json file. The setup command does not change lpm.json.
lpm setup ci npmrc and lpm setup local do not use lpm.json.
Create .npmrc for CI
If an npm-compatible client needs LPM.dev Registry authentication, run this command:
- name: Configure LPM.dev Registry access
run: lpm setup ci npmrc
env:
LPM_TOKEN: ${{ secrets.LPM_TOKEN }}
- run: npm ciThe command writes this scoped block to .npmrc in the current directory:
# LPM Registry (generated by lpm setup ci npmrc)
//lpm.dev/:_authToken=<resolved-token>
@lpm.dev:registry=https://lpm.dev/api/registry/
# End LPM RegistryOnly @lpm.dev/* packages use this route. Existing default registries and unrelated .npmrc lines stay unchanged.
The command replaces its previous generated block. On Unix, LPM CLI sets the file permissions to 0600.
CAUTION: Do not commit this .npmrc file. The file contains a literal bearer token.
This command does not add .npmrc to .gitignore. CI runners usually remove the workspace after the job.
Choose the CI credential
Without --oidc, the command uses one of these credentials:
- The global
--token <TOKEN>flag LPM_TOKEN- A valid token from
lpm login
If neither credential is available, the command stops before it changes .npmrc.
LPM CLI refreshes an expired browser session before it writes .npmrc. If the refresh fails, the command stops and keeps .npmrc unchanged.
Use --oidc to require a CI identity exchange:
lpm setup ci npmrc --oidcGitHub Actions needs permissions: id-token: write. GitLab.com CI needs LPM_OIDC_TOKEN with the https://lpm.dev audience.
An OIDC error stops the command. It does not use LPM_TOKEN or a saved login as a fallback.
Use --registry with another LPM-compatible registry:
lpm setup ci npmrc --registry https://registry.example.comA stored session applies only to that exact registry URL. The command appends /api/registry/ to the base URL in the generated scope route.
JSON output
If automation needs the file path and credential source, use JSON output:
lpm setup ci npmrc --jsonThe command still writes .npmrc. The JSON response replaces the token with <redacted>.
Create a local project token
If a local npm-compatible client needs a read-only project token, run these commands:
lpm login
lpm setup local
npm installThe LPM.dev Registry requires a valid browser-backed CLI session. The default token lifetime is 30 days.
Set a lifetime from 1 through 90 days:
lpm setup local --days 7
lpm setup local --days 90The command changes two project files:
.npmrcreceives a scoped, read-only token for@lpm.dev/*packages..gitignorereceives one.npmrcentry.
Existing .npmrc lines stay unchanged. A custom default registry also stays unchanged.
CAUTION: The .npmrc file contains a token. Keep the file outside version control.
Run lpm setup local again before the token expires. The command replaces the previous project token instead of creating active duplicates.
JSON output reports the paths, scope, and expiry. It does not include the token.
lpm setup local --jsonPrint a GitHub Actions workflow
Print the workflow fragment for the production secret environment:
lpm setup ci github-actionsSelect another environment with --env:
lpm setup ci github-actions --env stagingThe command prints three items:
- A complete GitHub Actions job fragment for
lpm env pull --oidc - An
lpm env oidc allowcommand for the repository - An instruction to configure the returned policy ID as
LPM_OIDC_POLICY_ID
The command prints output only. It does not create or change a workflow file.
Run the printed authorization command from a logged-in development machine. Then add the workflow fragment to .github/workflows/deploy.yml.
The authorization command also uploads protected material for the personal env project. Continue only when LPM CLI reports that CI escrow is enabled.
If the escrow upload fails, correct the error and run the same authorization command again. The command updates the matching policy.
When you run the authorization command, LPM CLI gets the immutable repository ID from GitHub. Private repositories need GITHUB_TOKEN, GH_TOKEN, or --repository-id.
The job fragment uses ubuntu-latest and includes all required job keys.
If your deployment needs another runner, change runs-on after you add the fragment.
The job needs id-token: write permission. It uses the vault ID from lpm.json as LPM_VAULT_ID.
The fragment reads LPM_OIDC_POLICY_ID from the GitHub vars context. Create it as a repository variable before the first pull. To use an environment variable instead, add environment: <name> to the job.
The aliases github and gha select the same target.
Print a GitLab CI workflow
Print the GitLab.com CI fragment:
lpm setup ci gitlab
lpm setup ci gitlab --env stagingThe command prints three items:
- A GitLab CI job fragment with an
LPM_OIDC_TOKENidentity token - An
lpm env oidc allowcommand for the numeric project ID - An instruction to configure the returned policy ID as
LPM_OIDC_POLICY_ID
The identity token uses the https://lpm.dev audience. The checked-out lpm.json file supplies the vault ID.
The command prints output only. It does not create or change .gitlab-ci.yml.
Run the printed authorization command from a logged-in development machine. Then add the job fragment to .gitlab-ci.yml.
The authorization command also uploads protected material for the personal env project. Continue only when LPM CLI reports that CI escrow is enabled.
Create LPM_OIDC_POLICY_ID as a GitLab CI/CD variable before the first pull. Mark it protected only when every branch or tag allowed by the OIDC policy is protected.
The alias gitlab-ci selects the same target. Self-managed GitLab issuers are not supported for this workflow.
Recover an interrupted setup
If lpm setup local reports an interrupted token replacement, run the same command again. Use the same registry URL.
lpm setup local --registry https://registry.example.comIf you want to switch to CI setup, finish the pending local replacement first. Then run lpm setup ci npmrc.
If a generated local block belongs to another registry, use that registry URL for recovery. LPM CLI does not move the token between registries.
Flags
| Command | Flag | Purpose |
|---|---|---|
lpm setup ci npmrc | -r, --registry <URL> | Use another LPM-compatible registry base URL |
lpm setup ci npmrc | --oidc | Require a CI OIDC exchange and disable credential fallback |
| GitHub Actions or GitLab CI | --env <NAME> | Set the secret environment in the workflow and policy command. The default is production |
lpm setup local | -d, --days <DAYS> | Set the read-only token lifetime from 1 through 90 days. The default is 30 |
Use only the flags listed for the selected target. The npmrc target rejects --env. The GitHub Actions and GitLab targets reject --registry and --oidc. The aliases use the same rules.
An invalid flag stops the command before it writes a file or prints a workflow fragment.
--json returns structured output for npmrc and local. The GitHub Actions and GitLab targets always print human-readable fragments.
See also
- Authentication - learn how LPM CLI selects credentials
lpm login, logout, and whoami- manage registry sessionslpm env- manage project secrets and OIDC policies- CI/CD setup - configure complete CI jobs
- Environment variables - use
LPM_TOKEN,LPM_OIDC_TOKEN, andLPM_VAULT_ID