yarnpkg/yarn · error · MessageError

unplugDisabled

Error message

unplugDisabled

What it means

Thrown at the top of 'yarn unplug' run when config.plugnplayEnabled is false. Unplugging copies a package out of the Plug'n'Play (PnP) zip cache for debugging; the operation is meaningless without PnP, so Yarn refuses to proceed.

Source

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

const path = require('path');

export function hasWrapper(commander: Object): boolean {
  return true;
}

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();

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Enable Plug'n'Play: in Yarn 1 set '--pnp' or add 'pnp-enable true' to .yarnrc, then re-install.
  2. In Yarn 2+ set 'nodeLinker: pnp' in .yarnrc.yml and run 'yarn install'.
  3. If you did not intend to use PnP, do not run 'yarn unplug' — it is PnP-only.

Example fix

# before (.yarnrc)
# (no pnp setting)
# after
pnp-enable true
Defensive patterns

Strategy: validation

Validate before calling

if (!config.plugnplayEnabled) {
  throw new Error("'yarn unplug' requires Plug'n'Play; enable it in .yarnrc/.yarnrc.yml and reinstall.");
}

Type guard

function isPnpEnabled(config: Config): boolean {
  return Boolean(config.plugnplayEnabled);
}

Prevention

When it happens

Trigger: Running 'yarn unplug [pkg]' in a project installed with the classic node-modules linker (PnP disabled), so config.plugnplayEnabled resolves false.

Common situations: Default Yarn install (no PnP); project upgraded from an older Yarn without enabling PnP; .yarnrc.yml lacks 'nodeLinker: pnp' (Yarn 2+) or .yarnrc lacks 'pnp-enable true' (Yarn 1).

Related errors


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