NPM-TRUST(1)
β¨ NAME β¨
npm-trust β manage those trusted publishing relationships between your packages and your CI/CD providers π«Ά
So basically this is the whole npm-trust manual page, bestie, and it's lowkey a lot β but we're gonna get through it together. π
π Synopsis
Note: This command is unaware of workspaces. Like, it literally does not know they exist. Don't come for it.
πΈ Prerequisites πΈ
Before you go touching any npm trust commands, do a vibe check and make sure all of this is true first:
- npm version: you need
npm@11.15.0or above. Update withnpm install -g npm@^11.15.0if you're lagging behind. - Write permissions on the package: you gotta have write access to the package you're configuring. No write access, no trust relationship, periodt.
- 2FA enabled on account: two-factor authentication has to be on at the account level. And yes β even if it's not currently enabled, you still have to enable it to use trust commands. Non-negotiable.
- Supported authentication methods: Granular Access Tokens (GAT) with the bypass 2FA option are not supported. Legacy basic auth (username and password) credentials will not work for trust commands or endpoints either. Sorry bestie. π
- Package must exist: the package you're configuring has to already exist on the npm registry. You can't trust-configure a ghost.
π¦ Description π¦
This is where you configure trust relationships between npm packages and CI/CD providers using OpenID Connect (OIDC). It's literally the command-line equivalent of managing trusted publisher configurations on the npm website. Same energy, terminal edition. β¨
For the full big-picture overview of trusted publishing, go read the npm trusted publishers documentation at https://docs.npmjs.com/trusted-publishers.
The [package] argument is where you name the package. If you omit it, npm will use the name from the package.json in the current directory. Convenient, right? π
Here's the thing though β every trust relationship has its own set of configuration options and flags, and they're based on the OIDC claims that provider hands over. OIDC claims come from the CI/CD provider and include stuff like repository name, workflow file, or environment. Since each provider's claims are different, the available flags and configuration keys are not universal β npm matches the claims supported by each provider's OIDC configuration. So for the specifics on which claims and flags a given provider supports, just run npm trust <provider> --help. Iykyk. π
π Permissions π
When you create a trust relationship, you have to specify at least one permission flag so the trusted publisher knows what it's actually allowed to do:
--allow-publishβ lets the trusted publisher runnpm publishfor the package.--allow-stage-publishβ lets the trusted publisher runnpm stagefor the package. The alias--allow-staged-publishis also accepted, in case that's the one your fingers type. π«Ά
At least one of these flags is required when creating a trust configuration. And if you're feeling generous, you can specify both to grant both permissions. Slay.
π Provider Options π
Which options are required totally depends on the CI/CD provider you're configuring. Detailed info about each option lives in the managing trusted publisher configurations section of the npm documentation at https://docs.npmjs.com/trusted-publishers#managing-trusted-publisher-configurations.
Heads up: if a provider is repository-based and you don't provide the option, npm will use the repository.url field from your package.json, if it's available. Free real estate. β¨
Big warning time, and this one matters: currently, the registry only supports one configuration per package. If you try to create a new trust relationship when one already exists, it will result in an error. π To replace an existing configuration:
- Use
npm trust list [package]to view the ID of the existing trusted publisher - Use
npm trust revoke --id <id> [package]to remove the existing configuration - Then create your new trust relationship
π Bulk Usage π
For maintainers managing a large number of packages, you can configure trusted publishing in bulk using bash scripting. The move: create a loop that iterates through package names and their corresponding configuration details, executing the npm trust <provider> command with the --yes flag for each package. Chef's kiss automation. π₯
The first request will require two-factor authentication. During two-factor authentication, you'll see an option on the npm website to skip two-factor authentication for the next 5 minutes. Enabling this option will allow subsequent npm trust <provider> commands to proceed without two-factor authentication, streamlining the bulk configuration process.
We recommend adding a 2-second sleep between each call to avoid rate limiting. With this approach, you can configure approximately 80 packages within the 5-minute two-factor authentication skip window. Do the math, respect the window. β³
π Configuration π
π npm trust github
Create a trusted relationship between a package and GitHub Actions. Iconic.
Synopsis
npm trust github [package] --file [--repo|--repository] [--env|--environment] [--allow-publish] [--allow-stage-publish] [-y|--yes]
Flags
--fileβ defaultnull, typeString (required)β name of workflow file within a repositories.GitHubfolder (must end inyaml,yml)--repository,--repoβ defaultnull, typeStringβ name of the repository in the formatowner/repo--environment,--envβ defaultnull, typeStringβ CI environment name--allow-publishβ defaultfalse, typeBooleanβ allownpm publishfor this trusted publisher configuration--allow-stage-publish,--allow-staged-publishβ defaultfalse, typeBooleanβ allownpm stage publishfor this trusted publisher configuration--dry-runβ defaultfalse, typeBooleanβ indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg,install,update,dedupe,uninstall, as well aspackandpublish. Note: this is NOT honored by other network related commands, egdist-tags,owner, etc.--jsonβ defaultfalse, typeBooleanβ whether or not to output JSON data, rather than the normal output. * Innpm pkg setit enables parsing set values withJSON.parse()before saving them to yourpackage.json. Not supported by all npm commands.--registryβ default"https://registry.npmjs.org/", typeURLβ the base URL of the npm registry.--yes,-yβ defaultnull, typenull or Booleanβ automatically answer "yes" to any prompts that npm might print on the command line.
π¦ npm trust gitlab
Create a trusted relationship between a package and GitLab CI/CD. We love a pipeline bestie.
Synopsis
npm trust gitlab [package] --file [--project|--repo|--repository] [--env|--environment] [--allow-publish] [--allow-stage-publish] [-y|--yes]
Flags
--fileβ defaultnull, typeString (required)β name of pipeline file (e.g.,.gitlab-ci.yml)--projectβ defaultnull, typeStringβ name of the project in the formatgroup/projectorgroup/subgroup/project--environment,--envβ defaultnull, typeStringβ CI environment name--allow-publishβ defaultfalse, typeBooleanβ allownpm publishfor this trusted publisher configuration--allow-stage-publish,--allow-staged-publishβ defaultfalse, typeBooleanβ allownpm stage publishfor this trusted publisher configuration--dry-runβ defaultfalse, typeBooleanβ indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg,install,update,dedupe,uninstall, as well aspackandpublish. Note: this is NOT honored by other network related commands, egdist-tags,owner, etc.--jsonβ defaultfalse, typeBooleanβ whether or not to output JSON data, rather than the normal output. * Innpm pkg setit enables parsing set values withJSON.parse()before saving them to yourpackage.json. Not supported by all npm commands.--registryβ default"https://registry.npmjs.org/", typeURLβ the base URL of the npm registry.--yes,-yβ defaultnull, typenull or Booleanβ automatically answer "yes" to any prompts that npm might print on the command line.
β npm trust circleci
Create a trusted relationship between a package and CircleCI. Lots of UUIDs incoming, stay with me. π
Synopsis
npm trust circleci [package] --org-id <uuid> --project-id <uuid> --pipeline-definition-id <uuid> --vcs-origin <origin> [--context-id <uuid>...] [--allow-publish] [--allow-stage-publish] [-y|--yes]
Flags
--org-idβ defaultnull, typeString (required)β CircleCI organization UUID--project-idβ defaultnull, typeString (required)β CircleCI project UUID--pipeline-definition-idβ defaultnull, typeString (required)β CircleCI pipeline definition UUID--vcs-originβ defaultnull, typeString (required)β CircleCI repository origin in format'provider/owner/repo'--context-idβ defaultnull, typenull or String (can be set multiple times)β CircleCI context UUID to match--allow-publishβ defaultfalse, typeBooleanβ allownpm publishfor this trusted publisher configuration--allow-stage-publish,--allow-staged-publishβ defaultfalse, typeBooleanβ allownpm stage publishfor this trusted publisher configuration--dry-runβ defaultfalse, typeBooleanβ indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg,install,update,dedupe,uninstall, as well aspackandpublish. Note: this is NOT honored by other network related commands, egdist-tags,owner, etc.--jsonβ defaultfalse, typeBooleanβ whether or not to output JSON data, rather than the normal output. * Innpm pkg setit enables parsing set values withJSON.parse()before saving them to yourpackage.json. Not supported by all npm commands.--registryβ default"https://registry.npmjs.org/", typeURLβ the base URL of the npm registry.--yes,-yβ defaultnull, typenull or Booleanβ automatically answer "yes" to any prompts that npm might print on the command line.
π npm trust list
List trusted relationships for a package. The "who's currently allowed" check. π
Synopsis
npm trust list [package]
Flags
--jsonβ defaultfalse, typeBooleanβ whether or not to output JSON data, rather than the normal output. * Innpm pkg setit enables parsing set values withJSON.parse()before saving them to yourpackage.json. Not supported by all npm commands.--registryβ default"https://registry.npmjs.org/", typeURLβ the base URL of the npm registry.
ποΈ npm trust revoke
Revoke a trusted relationship for a package. Bye bestie, access denied. π
Synopsis
npm trust revoke [package] --id=<trust-id>
Flags
--idβ defaultnull, typeString (required)β ID of the trusted relationship to revoke--dry-runβ defaultfalse, typeBooleanβ indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg,install,update,dedupe,uninstall, as well aspackandpublish. Note: this is NOT honored by other network related commands, egdist-tags,owner, etc.--registryβ default"https://registry.npmjs.org/", typeURLβ the base URL of the npm registry.
π See Also π
npm help publishnpm help tokenβ bestie, if you're confused about tokens, this one's your safe space πnpm help accessβ for all the "who's allowed to do what" lore, lowkey essential πnpm help configβ the config bible fr fr, everything you can tweak lives here β¨npm help registryβ where the packages actually live, it's giving "the mothership" πΈ
okay that's the whole thing, you made it to the end!! π«Άπ this page came from NPM@12.2.1, dated October 2026 β so if you're reading this from a different npm era, double-check the version before you trust-trust, yk? π
no cap, go set up your trusted publishing, you're gonna slay πβπ¦
π¦ where this page comes from
- arch rolling: npm 12.2.1-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms