yarnpkg/yarn · error · MessageError

packageNotFoundRegistry

Error message

packageNotFoundRegistry

What it means

Thrown by the 'list' subcommand after config.registries.npm.request('/-/package/<name>/dist-tags') returns a falsy value (null/undefined). The registry returned no dist-tags payload, meaning the package is not published on the configured registry.

Source

Thrown at src/cli/commands/tag.js:45

    throw new MessageError(config.reporter.lang('unknownPackageName'));
  }
}

async function list(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {
  const name = await getName(args, config);

  reporter.step(1, 1, reporter.lang('gettingTags'));
  const tags = await config.registries.npm.request(`-/package/${name}/dist-tags`);

  if (tags) {
    reporter.info(`Package ${name}`);
    for (const name in tags) {
      reporter.info(`${name}: ${tags[name]}`);
    }
  }

  if (!tags) {
    throw new MessageError(reporter.lang('packageNotFoundRegistry', name, 'npm'));
  }
}

async function remove(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<boolean> {
  if (args.length !== 2) {
    return false;
  }

  const name = await getName(args, config);
  const tag = args.shift();

  reporter.step(1, 3, reporter.lang('loggingIn'));
  const revoke = await getToken(config, reporter, name);

  reporter.step(2, 3, reporter.lang('deletingTags'));
  const result = await config.registries.npm.request(`-/package/${name}/dist-tags/${encodeURI(tag)}`, {
    method: 'DELETE',
  });

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Publish the package first with 'yarn publish' (or 'npm publish').
  2. Check the registry configuration: 'yarn config get registry' and any scope-registry mapping in .npmrc.
  3. Confirm the package name spelling and scope match what is published.
  4. If the package is private/unpublishable, do not run 'yarn tag' against it.

Example fix

# before
$ yarn tag my-pkg   # not yet published
# after
$ yarn publish
$ yarn tag my-pkg
Defensive patterns

Strategy: try-catch

Validate before calling

const tags = await config.registries.npm.request(`-/package/${name}/dist-tags`);
if (!tags) {
  throw new Error(`Package "${name}" has no dist-tags on the configured registry; publish it first.`);
}

Type guard

function hasDistTags(v: unknown): v is Record<string, string> {
  return v != null && typeof v === 'object' && !Array.isArray(v);
}

Try / catch

try {
  const tags = await config.registries.npm.request(`-/package/${name}/dist-tags`);
  if (!tags) throw new Error(`packageNotFoundRegistry: ${name}`);
} catch (err) {
  // distinguish 404 (not published) from network errors
  if (isHttpNotFound(err)) {
    console.error(`Package ${name} is not published on this registry.`);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Running 'yarn tag' (list) for a package name that the registry does not know about, so the request resolves to null (404/empty). The `if (!tags)` guard fires.

Common situations: Package was never published; scoped package published to a private registry but queried on npmjs.org (or vice versa); wrong registry URL in .npmrc/.yarnrc; typo in the name; package is private.

Related errors


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