nodejs/node · error · Error
Package name must be specified either as an argument or in…
Error message
Package name must be specified either as an argument or in package.json file
What it means
Thrown by the CircleCI trust provider's `flagsToOptions` when neither a positional argument nor a `package.json` `name` field yields a package name. The trust record needs a package name to bind the OIDC claim to, and it must come from one of those two sources.
Solutions
- Pass the package name as the first positional argument to the command.
- Add a `"name"` field to the local package.json.
- Run the command from the package root that contains a valid package.json.
Example fix
// before npm trust circleci --org-id ... // no name, no package.json // after npm trust circleci @myscope/mypkg --org-id ... // or add to package.json: "name": "@myscope/mypkg"
Defensive patterns
Strategy: validation
Validate before calling
function resolvePkgName(positionalArg, pkgJson) {
const name = positionalArg || pkgJson?.name
if (!name) {
throw new Error('Package name required: pass it positionally or set "name" in package.json')
}
return name
} Prevention
- Ensure package.json has a "name" field in every package root.
- Pass the package name explicitly when running outside a package directory.
- Validate name presence in release/trust scripts.
When it happens
Trigger: `positionalArgs[0]` is falsy and `optionalPkgJson().name` is also falsy/undefined.
Common situations: Running the command in a directory without a package.json (or with one lacking a `name`); running outside any package and not passing the name positionally.
Related errors
- org-id is required
- pipeline-definition-id is required
- project-id is required
- vcs-origin is required
- vcs-origin must be in format 'provider/owner/repo'
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/6733fa549f409302.
Report an issue: GitHub.
Appendix: source
Thrown at deps/npm/lib/commands/trust/circleci.js:118
...(body.id) && { id: body.id },
...(body.type) && { type: body.type },
...(body.claims?.['oidc.circleci.com/org-id']) && { orgId: body.claims['oidc.circleci.com/org-id'] },
...(body.claims?.['oidc.circleci.com/project-id']) && { projectId: body.claims['oidc.circleci.com/project-id'] },
...(body.claims?.['oidc.circleci.com/pipeline-definition-id']) && {
pipelineDefinitionId: body.claims['oidc.circleci.com/pipeline-definition-id'],
},
...(body.claims?.['oidc.circleci.com/vcs-origin']) && { vcsOrigin: body.claims['oidc.circleci.com/vcs-origin'] },
...(body.claims?.['oidc.circleci.com/context-ids']) && { contextIds: body.claims['oidc.circleci.com/context-ids'] },
}
}
// Override flagsToOptions since CircleCI doesn't use file/entity pattern
async flagsToOptions ({ positionalArgs, flags }) {
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')
}View on GitHub (pinned to 1b2de5e052)