pnpm/pnpm · error · PnpmError

TOO_MANY_PARAMS

TOO_MANY_PARAMS

Error message

`pnpm cache view` only accepts one package name

What it means

Usage error from `pnpm cache view` when more than one package name is supplied (`params.length > 2`, i.e. `view` plus 2+ names). The viewer resolves a single package's cached metadata, so extra arguments are rejected rather than silently ignored.

Source

Thrown at pnpm11/cache/commands/src/cache.cmd.ts:106

      // A package's metadata can be cached under any of the metadata directories
      // depending on the resolution mode used when it was fetched.
      const deleted = await Promise.all(
        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
          cacheDelete({
            ...opts,
            cacheDir: path.join(opts.cacheDir, metaDir),
            registry: opts.cliOptions['registry'],
          }, params.slice(1))
        )
      )
      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
    }
    case 'view': {
      if (!params[1]) {
        throw new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache view` requires the package name')
      }
      if (params.length > 2) {
        throw new PnpmError('TOO_MANY_PARAMS', '`pnpm cache view` only accepts one package name')
      }
      const storeDir = await getStorePath({
        pkgRoot: process.cwd(),
        storePath: opts.storeDir,
        pnpmHomeDir: opts.pnpmHomeDir,
      })
      return cacheView({
        ...opts,
        cacheDir,
        storeDir,
        registry: opts.cliOptions['registry'],
      }, params[1])
    }
    default:
      return help()
  }
}

View on GitHub (pinned to 5b11d3a15b)

Solutions

  1. Query one package per invocation: `pnpm cache view foo` then `pnpm cache view bar`
  2. Quote globs or loop over candidates in scripts instead of passing them all at once

Example fix

# before
pnpm cache view lodash express
# after
pnpm cache view lodash && pnpm cache view express
Defensive patterns

Strategy: validation

Validate before calling

if (params.length > 2) {
  console.error('pnpm cache view accepts exactly one package name')
  process.exit(1)
}

Prevention

When it happens

Trigger: `pnpm cache view foo bar`, or a script looping incorrectly so multiple names land in one invocation; also shell glob expansion producing several matches.

Common situations: Assuming view behaves like `pnpm cache delete` which accepts broader input; unquoted globs such as `pnpm cache view @scope/*` expanding to multiple names.

Related errors


AI-assisted analysis of pnpm/pnpm@5b11d3a15b (2026-08-16). Data as JSON: /api/errors/8c6c3c70a12c8d54. Report an issue: GitHub.