yarnpkg/yarn · error · MessageError

Unknown registry resolver $0

Error message

Unknown registry resolver $0

What it means

Thrown by PackageRequest.getRegistryResolver() when registryResolvers[this.registry] is undefined. Yarn maintains a map of registry names to resolver classes; if a package's registry string has no registered resolver, it cannot proceed with resolution. This is a lookup-table miss, not a network error.

Source

Thrown at src/package-request.js:143

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

  async normalizeRange(pattern: string): Promise<string> {
    if (pattern.indexOf(':') > -1 || pattern.indexOf('@') > -1 || getExoticResolver(pattern)) {
      return pattern;
    }

    if (!semver.validRange(pattern)) {
      try {
        if (await fs.exists(path.join(this.config.cwd, pattern, constants.NODE_PACKAGE_JSON))) {
          this.reporter.warn(this.reporter.lang('implicitFileDeprecated', pattern));
          return `file:${pattern}`;
        }
      } catch (err) {
        // pass
      }
    }

View on GitHub (pinned to c2dda503f3)

Solutions

  1. Verify the registry name in .yarnrc/.npmrc matches a known resolver (typically 'npm')
  2. Check package._registry fields in yarn.lock for unknown registry strings
  3. Delete yarn.lock and run yarn install to regenerate with the correct registry references
  4. Ensure any custom registry resolver plugin is properly loaded before resolution

Example fix

// before (.yarnrc)
registry "mycustomreg"
// after
registry "npm"
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN_REGISTRIES = Object.keys(registryResolvers);
if (!KNOWN_REGISTRIES.includes(pkg._registry)) {
  throw new Error(`Registry '${pkg._registry}' has no resolver. Known: ${KNOWN_REGISTRIES.join(', ')}`);
}

Type guard

function isKnownRegistry(registry: string): boolean {
  return Object.prototype.hasOwnProperty.call(registryResolvers, registry);
}

Try / catch

try {
  const Resolver = request.getRegistryResolver();
} catch (e) {
  if (e.message.includes('Unknown registry resolver')) {
    // log and fall back to the default npm registry
  }
}

Prevention

When it happens

Trigger: A package manifest or lockfile sets _registry to a string with no entry in registryResolvers (e.g., a typo or unknown registry type). Called from getRegistryResolver() during the resolution pipeline.

Common situations: Misconfigured .yarnrc/.npmrc with a non-standard registry name; lockfiles from a newer Yarn referencing registries an older version doesn't know; custom plugin/registry that wasn't registered.

Related errors


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