yarnpkg/yarn · error · MessageError

Couldn't find package $0 required by $1 on the $2 registry.

Error message

Couldn't find package $0 required by $1 on the $2 registry.

What it means

Thrown by `PackageRequest.getConstrainedResolvedVersion` when the registry resolver's `resolve()` throws a non-MessageError AND the current request has a `parentRequest` with a `pattern`. Instead of surfacing the raw (often cryptic, e.g. network) error, Yarn wraps it into a human-readable message naming the required package, the requirer, and the registry.

Source

Thrown at src/package-request.js:126

      data = Object.assign({}, data);

      // this is so the returned package response uses the overridden name. ie. if the
      // package's actual name is `bar`, but it's been specified in the manifest like:
      //   "foo": "http://foo.com/bar.tar.gz"
      // then we use the foo name
      data.name = name;
      return data;
    }

    const Resolver = this.getRegistryResolver();
    const resolver = new Resolver(this, name, range);
    try {
      return await resolver.resolve();
    } catch (err) {
      // if it is not an error thrown by yarn and it has a parent request,
      // thow a more readable error
      if (!(err instanceof MessageError) && this.parentRequest && this.parentRequest.pattern) {
        throw new MessageError(
          this.reporter.lang('requiredPackageNotFoundRegistry', pattern, this.parentRequest.pattern, this.registry),
        );
      }
      throw err;
    }
  }

  /**
   * Get the registry resolver associated with this package request.
   */

  getRegistryResolver(): Function {
    const Resolver = registryResolvers[this.registry];
    if (Resolver) {
      return Resolver;
    } else {
      throw new MessageError(this.reporter.lang('unknownRegistryResolver', this.registry));
    }

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Verify the package and version exist on the named registry: `npm view <name>@<range>`.
  2. Check the requirer's declared range for typos and pin a known-good version.
  3. For scoped/private packages, confirm your `.npmrc`/`yarn config` maps the scope to the correct registry and that auth is valid.
  4. For network errors, retry; if persistent, check connectivity, proxy (`http_proxy`), and registry status.
  5. If the package was unpublished, update the requirer to a replacement or available version.

Example fix

// before (parent requires a non-existent version)
"dependencies": {
  "left-pad": "^99.0.0"
}
// after
"dependencies": {
  "left-pad": "^1.3.0"
}
# then:
yarn install
Defensive patterns

Strategy: retry

Validate before calling

const semver = require('semver');
async function verifyPackageResolvable(registry, name, range) {
  const resp = await fetch(`${registry}/${encodeURIComponent(name)}`);
  if (!resp.ok) throw new Error(`Package '${name}' not reachable on ${registry}`);
  const data = await resp.json();
  const versions = Object.keys(data.versions || {});
  if (!versions.some(v => semver.satisfies(v, range))) {
    throw new Error(`No version of '${name}' satisfies '${range}' on ${registry}.`);
  }
}

Try / catch

try {
  return await resolver.resolve();
} catch (err) {
  if (!(err instanceof MessageError)) {
    // transient network/registry error — retry with backoff
    await new Promise(r => setTimeout(r, 1000));
    return await resolver.resolve();
  }
  throw err;
}

Prevention

When it happens

Trigger: A transitive dependency cannot be resolved from the registry: the package was unpublished, the version range matches nothing, the registry is unreachable (network error surfaces as non-MessageError), or a private registry auth failed. Because there is a parent request, Yarn reports which package required the missing one.

Common situations: A dependency was unpublished or yanked. A version range typo in a dependency (e.g. `^9.0.0` for a package at `8.x`). Private registry token expired or scope misconfigured (`@scope` not pointing at the right registry). Network/firewall blocking registry access.

Related errors


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