{"record":{"id":"ded8e1e47a113309","repo":"nodejs/node","slug":"repository-in-package-json-is-not-a-providerenti","errorCode":null,"errorMessage":"Repository in package.json is not a ${providerEntity}","messagePattern":"Repository in package\\.json is not a (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/trust-cmd.js","lineNumber":288,"sourceCode":"\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      }\n    }\n\n    if (!entity && matchPkg) {\n      throw new Error(`${providerEntity} must be specified with ${entityKey} option or inferred from the package.json repository field`)\n    }\n    if (!entity) {\n      throw new Error(`${providerEntity} must be specified with ${entityKey} option`)\n    }\n\n    this.validateEntity(entity)\n","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/trust-cmd.js#L270-L306","documentation":"Thrown by TrustCommand.flagsToOptions when the package.json repository resolves (via hosted-git-info) to a DIFFERENT provider type than the command (e.g. a GitHub URL while running `npm trust gitlab`) AND no explicit `--project`/`--repo` flag was given. With a mismatched type the inferred entity is unreliable, so the command refuses to silently use it; providing the flag demotes the same condition to a warning instead of an error.","triggerScenarios":"package.json `repository` points to github.com but you run `npm trust gitlab` without `--project`; or repository is a gitlab URL but you run `npm trust github`. invalidPkgJsonProviderType = matchPkg && git && git.type !== name; the throw fires inside that branch when flags[entityKey] is absent.","commonSituations":"Mirrored repos (canonical on GitHub, mirror on GitLab) where repository still points to the original; renaming a repo and leaving stale metadata; running the wrong provider subcommand.","solutions":["Pass the explicit entity flag for the provider you are configuring: `--project group/proj` for gitlab, `--repo owner/repo` for github.","Update the package.json `repository` field to match the provider you intend to trust.","Switch to the correct provider subcommand that matches your repository (`npm trust github` vs `npm trust gitlab`)."],"exampleFix":"// before\n// package.json: \"repository\": \"github:owner/repo\"\nnpm trust gitlab --file .gitlab-ci.yml --allow-publish\n// after\n// keep package.json as-is, supply the project explicitly\nnpm trust gitlab --file .gitlab-ci.yml --project gl-group/gl-proj --allow-publish","handlingStrategy":"validation","validationCode":"const git = gitinfo.fromUrl(pkg.repository?.url || pkg.repository)\nif (git && git.type !== providerName && !flags[entityKey]) {\n  throw new Error(`package.json repository is a ${git.type} URL but you are configuring ${providerName}; pass --${entityKey} explicitly`)\n}","typeGuard":"const repoTypeMatchesProvider = (pkg, providerName) => {\n  const info = gitinfo.fromUrl(pkg.repository?.url || pkg.repository)\n  return !info || info.type === providerName\n}","tryCatchPattern":"try {\n  await createConfigCommand(...)\n} catch (err) {\n  if (/Repository in package.json is not a/i.test(err.message)) {\n    // pass the explicit entity flag (e.g. --project group/proj) and retry\n  } else { throw err }\n}","preventionTips":["Keep package.json `repository` aligned with the canonical source provider.","Pass the explicit entity flag whenever repository metadata may be stale.","Use full HTTPS URLs in `repository.url` so hosted-git-info parses reliably."],"tags":["validation","trust","package-json","repository"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}