{"record":{"id":"57209107936f6f5f","repo":"nodejs/node","slug":"providerfile-must-be-specified-with-the-file-op","errorCode":null,"errorMessage":"${providerFile} must be specified with the file option","messagePattern":"(.+?) must be specified with the file option","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/trust-cmd.js","lineNumber":277,"sourceCode":"    let entitySource\n\n    if (flags[entityKey]) {\n      entity = flags[entityKey]\n      entitySource = 'flag'\n    } else if (!invalidPkgJsonProviderType && git?.repository) {\n      entity = git.repository\n      entitySource = 'package.json'\n    }\n    const mismatchPkgJsonRepository = matchPkg && git && entity !== git.repository\n    const usedRepositoryInPkgJson = entitySource === 'package.json'\n\n    const warnings = []\n    if (!pkgName) {\n      throw new Error('Package name must be specified either as an argument or in package.json file')\n    }\n\n    if (!flags.file) {\n      throw new Error(`${providerFile} must be specified with the file option`)\n    }\n    if (!flags.file.endsWith('.yml') && !flags.file.endsWith('.yaml')) {\n      throw new Error(`${providerFile} must end in .yml or .yaml`)\n    }\n\n    this.validateFile?.(flags.file)\n\n    if (invalidPkgJsonProviderType) {\n      const message = this.warnString`Repository in package.json is not a ${providerEntity}`\n      if (!flags[entityKey]) {\n        throw new Error(message)\n      } else {\n        warnings.push(message)\n      }\n    } else {\n      if (mismatchPkgJsonRepository) {\n        warnings.push(this.warnString`Repository in package.json (${git.repository}) differs from provided ${providerEntity} (${entity})`)\n      }","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/trust-cmd.js#L259-L295","documentation":"Thrown by TrustCommand.flagsToOptions when `--file` was not provided (flags.file is falsy). The pipeline file is a required input: it becomes the ci_config_ref_uri claim and is the core of a trusted publishing config. The check runs right after the package-name guard.","triggerScenarios":"Any `npm trust <provider>` create invocation without `--file`. Note the `file` Definition is required:true for GitLab, but flagsToOptions guards defensively because not all providers enforce required at parse time identically.","commonSituations":"Forgetting the flag; assuming the default `.gitlab-ci.yml` is implied (it is not); typo in the flag name.","solutions":["Add `--file <pipeline-file>`, e.g. `--file .gitlab-ci.yml`.","Confirm the filename is correct with `ls` in the repo root.","Run with `--usage` to see the required options for the provider."],"exampleFix":"// before\nnpm trust gitlab --project g/p --allow-publish\n// after\nnpm trust gitlab --file .gitlab-ci.yml --project g/p --allow-publish","handlingStrategy":"validation","validationCode":"if (!flags.file) {\n  throw new Error('Trust config requires --file pointing to the pipeline definition')\n}","typeGuard":"const hasFileFlag = (flags) =>\n  Boolean(flags && typeof flags.file === 'string' && flags.file.length > 0)","tryCatchPattern":"try {\n  await createConfigCommand(...)\n} catch (err) {\n  if (/must be specified with the file option/i.test(err.message)) {\n    // ask user for the pipeline filename, set flags.file, retry\n  } else { throw err }\n}","preventionTips":["Always pass --file when creating a trust config.","Verify the file exists in the repository root before running.","Template your trust command with the file name baked in."],"tags":["validation","trust","cli-args"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}