yarnpkg/yarn · error · MessageError

noArguments

Error message

noArguments

What it means

Thrown by 'yarn unplug' when --clear-all is supplied together with positional args. --clear-all already targets every unplugged package, so naming specific packages is contradictory and rejected.

Source

Thrown at src/cli/commands/unplug.js:33

export function setFlags(commander: Object) {
  commander.description(
    'Temporarily copies a package (with an optional @range suffix) outside of the global cache for debugging purposes',
  );
  commander.usage('unplug [packages ...] [flags]');
  commander.option('--clear', 'Delete the selected packages');
  commander.option('--clear-all', 'Delete all unplugged packages');
}

export async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {
  if (!config.plugnplayEnabled) {
    throw new MessageError(reporter.lang('unplugDisabled'));
  }
  if (!args.length && flags.clear) {
    throw new MessageError(reporter.lang('tooFewArguments', 1));
  }
  if (args.length && flags.clearAll) {
    throw new MessageError(reporter.lang('noArguments'));
  }

  if (flags.clearAll) {
    await clearAll(config);
  } else if (flags.clear) {
    await clearSome(config, new Set(args));
  } else if (args.length > 0) {
    const lockfile = await Lockfile.fromDirectory(config.lockfileFolder, reporter);
    await wrapLifecycle(config, flags, async () => {
      const install = new Install(flags, config, reporter, lockfile);
      install.linker.unplugged = args;
      await install.init();
    });
  }

  const unpluggedPackageFolders = await config.listUnpluggedPackageFolders();

  for (const target of unpluggedPackageFolders.values()) {

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Drop the package args: 'yarn unplug --clear-all'.
  2. If you want to clear only specific packages, use '--clear <pkg>...' instead of '--clear-all'.

Example fix

# before
$ yarn unplug --clear-all lodash
# after
$ yarn unplug --clear-all
Defensive patterns

Strategy: validation

Validate before calling

if (flags.clearAll && Array.isArray(args) && args.length > 0) {
  throw new Error("'--clear-all' takes no package args; remove them or use '--clear <pkgs>'.");
}

Type guard

function clearAllIsClean(flags: Object, args: string[]): boolean {
  return Boolean(flags.clearAll) && args.length === 0;
}

Prevention

When it happens

Trigger: Running 'yarn unplug --clear-all <pkg>' where args.length > 0, so the condition (args.length && flags.clearAll) is true.

Common situations: User mixed flags (copied --clear syntax then switched to --clear-all); habit of always naming packages.

Related errors


AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13). Data as JSON: /api/errors/597d48f94bf639e2. Report an issue: GitHub.