nodejs/node · error · Error

project-id is required

Error message

project-id is required

What it means

Thrown by the CircleCI trust provider's `flagsToOptions` when the `--project-id` flag is missing or empty. The project UUID is required to scope the trust record to a specific CircleCI project.

Source

Thrown at deps/npm/lib/commands/trust/circleci.js:132

    const content = await this.optionalPkgJson()
    const pkgName = positionalArgs[0] || content.name

    if (!pkgName) {
      throw new Error('Package name must be specified either as an argument or in package.json file')
    }

    const orgId = flags['org-id']
    const projectId = flags['project-id']
    const pipelineDefinitionId = flags['pipeline-definition-id']
    const vcsOrigin = flags['vcs-origin']
    const contextIds = flags['context-id']

    // Validate required flags
    if (!orgId) {
      throw new Error('org-id is required')
    }
    if (!projectId) {
      throw new Error('project-id is required')
    }
    if (!pipelineDefinitionId) {
      throw new Error('pipeline-definition-id is required')
    }
    if (!vcsOrigin) {
      throw new Error('vcs-origin is required')
    }

    // Validate formats
    this.validateUuid(orgId, 'org-id')
    this.validateUuid(projectId, 'project-id')
    this.validateUuid(pipelineDefinitionId, 'pipeline-definition-id')
    this.validateVcsOrigin(vcsOrigin)
    if (contextIds?.length > 0) {
      for (const contextId of contextIds) {
        this.validateUuid(contextId, 'context-id')
      }
    }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Pass `--project-id <uuid>` with the CircleCI project UUID.
  2. Obtain it from CircleCI Project Settings; it must be a UUID (`validateUuid` runs next).
  3. Distinguish org-id (organization level) from project-id (repository level).

Example fix

// before
npm trust circleci mypkg --org-id <uuid> ...
// after
npm trust circleci mypkg --org-id <uuid> --project-id <uuid> ...
Defensive patterns

Strategy: validation

Validate before calling

function assertRequiredFlag(flags, name) {
  if (!flags[name]) throw new Error(`${name} is required`)
  return flags[name]
}
assertRequiredFlag(flags, 'project-id')

Type guard

function hasProjectId(flags) {
  return Boolean(flags && flags['project-id'])
}

Prevention

When it happens

Trigger: `flags['project-id']` is falsy during required-flag validation (checked after org-id).

Common situations: Mixing up org-id and project-id; omitting the flag; passing the project slug instead of its UUID.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/4b475cd4c0a41715. Report an issue: GitHub.