nodejs/node · error · Error

No dependencies found matching

Error message

No dependencies found matching ${args.join(', ')}

What it means

`npm explain <spec>...` collects tree nodes matching each argument, applying any --workspace filter. If the resulting node set is empty (no arg matched anything, or all matches were filtered out) it throws naming the requested args.

Solutions

  1. Confirm the dependency is installed: `npm ls <pkg>`
  2. Correct the spec or package name spelling
  3. Drop or widen the --workspace filter if it is excluding the matching node
  4. Run `npm install` first if the tree is incomplete
Defensive patterns

Strategy: validation

Validate before calling

async function depExplainable(arborist, args, filterSet) {
  const tree = await arborist.loadActual()
  let matched = 0
  for (const arg of args) for (const node of getNodes(tree, arg)) {
    if (!filterSet || filterSet.size === 0 || filterSet.has(node)) matched++
  }
  return matched > 0
}

Type guard

function anyNodeMatches(nodes) { return nodes.size > 0 }

Try / catch

try {
  await runNpm('explain', args)
} catch (e) {
  if (/No dependencies found/.test(e.message)) { await runNpm('ls') /* inspect tree */ }
  else throw e
}

Prevention

When it happens

Trigger: Running `npm explain <pkg>` where <pkg> is not installed in the current tree; a typo; a dep present only under a workspace excluded by your --workspace filter.

Common situations: Querying a transitive dep that was deduped/removed; wrong package name; running explain from the wrong directory (no node_modules).

Related errors


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

Appendix: source

Thrown at deps/npm/lib/commands/explain.js:56

      this.filterSet = arb.workspaceDependencySet(tree, this.workspaceNames)
    } else if (!this.npm.flatOptions.workspacesEnabled) {
      this.filterSet =
        arb.excludeWorkspacesDependencySet(tree)
    }

    const nodes = new Set()
    for (const arg of args) {
      for (const node of this.getNodes(tree, arg)) {
        const filteredOut = this.filterSet
          && this.filterSet.size > 0
          && !this.filterSet.has(node)
        if (!filteredOut) {
          nodes.add(node)
        }
      }
    }
    if (nodes.size === 0) {
      throw new Error(`No dependencies found matching ${args.join(', ')}`)
    }

    const expls = []
    for (const node of nodes) {
      const { extraneous, dev, optional, devOptional, peer, inBundle, overridden } = node
      const expl = node.explain()
      if (extraneous) {
        expl.extraneous = true
      } else {
        expl.dev = dev
        expl.optional = optional
        expl.devOptional = devOptional
        expl.peer = peer
        expl.bundled = inBundle
        expl.overridden = overridden
      }
      expls.push(expl)
    }

View on GitHub (pinned to 1b2de5e052)