badges/shields · error · InvalidParameter

${kind} dependency not found

Error message

${kind} dependency not found

What it means

package-json-helpers.getDependencyVersion looks up a wanted dependency inside the dependency map selected by `kind` (e.g. dependencies, devDependencies, peerDependencies). If the dependency is not present in that map, it throws InvalidParameter with `${kind} dependency not found`. This signals the caller asked for a dependency/version combination that does not exist in the fetched package.json.

Source

Thrown at services/package-json-helpers.js:70

  wantedDependency,
  dependencies,
  devDependencies,
  peerDependencies,
  optionalDependencies,
}) {
  const dependencyMaps = {
    peer: peerDependencies,
    optional: optionalDependencies,
    dev: devDependencies,
    prod: dependencies,
  }

  if (!(kind in dependencyMaps)) {
    throw Error(`Not very kind: ${kind}`)
  }
  const range = dependencyMaps[kind][wantedDependency]
  if (range === undefined) {
    throw new InvalidParameter({
      prettyMessage: `${kind} dependency not found`,
    })
  }

  return range
}

export { isDependencyMap, isPackageJsonWithDependencies, getDependencyVersion }

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Check the dependency exists in the specified section of the target repo's package.json and correct the requested name.
  2. If unsure which section holds it, use the badge variant that scans all dependency kinds, or switch the kind parameter.
  3. Verify spelling/casing of the dependency name exactly matches package.json.

Example fix

// before
/github/dependency/json/user/repo/devDependencies/lodash  (lodash is in dependencies)
// after
/github/dependency/json/user/repo/dependencies/lodash
Defensive patterns

Strategy: validation

Validate before calling

const pkg = require('./package.json')
const maps = { dependencies: pkg.dependencies, devDependencies: pkg.devDependencies, peerDependencies: pkg.peerDependencies }
if (!(wantedDependency in (maps[kind] || {}))) {
  throw new Error(`${wantedDependency} is not in ${kind}`)
}

Type guard

function dependencyExists(pkg, kind, name) {
  const map = pkg && pkg[kind]
  return map != null && typeof map === 'object' && name in map
}

Prevention

When it happens

Trigger: Calling a dependency badge with a package name (`wantedDependency`) that is absent from the requested dependency kind's map in the target repo's package.json — e.g. asking for a devDependency that is only a regular dependency.

Common situations: Badges pinned to the wrong dependency kind; packages renamed or moved between dependency sections across releases; typos in the dependency name.

Understand the failure class

Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.

Related errors


AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30). Data as JSON: /api/errors/df24f8be043d6d91. Report an issue: GitHub.