jestjs/jest · error · Error

Resolver located at ${resolver} does not export anything

Error message

Resolver located at ${resolver} does not export anything

What it means

Thrown inside loadResolver when `require(resolver)` returns null or undefined, meaning the user-configured resolver module has no exports at all. Jest cannot use a resolver that exports nothing, so it aborts before any resolution is attempted.

Source

Thrown at packages/jest-resolve/src/resolver.ts:945

  return error;
};

type ResolverSyncObject = {sync: SyncResolver; async?: AsyncResolver};
type ResolverAsyncObject = {sync?: SyncResolver; async: AsyncResolver};
export type ResolverObject = ResolverSyncObject | ResolverAsyncObject;

function loadResolver(
  resolver: string | undefined | null,
): SyncResolver | ResolverObject {
  if (resolver == null) {
    return defaultResolver;
  }

  const loadedResolver = require(resolver);

  if (loadedResolver == null) {
    throw new Error(`Resolver located at ${resolver} does not export anything`);
  }

  if (typeof loadedResolver === 'function') {
    return loadedResolver as SyncResolver;
  }

  if (
    typeof loadedResolver === 'object' &&
    (loadedResolver.sync != null || loadedResolver.async != null)
  ) {
    return loadedResolver as ResolverObject;
  }

  throw new Error(
    `Resolver located at ${resolver} does not export a function or an object with "sync" and "async" props`,
  );
}

View on GitHub (pinned to f49721c78e)

Solutions

  1. Confirm the resolver file has an export: `module.exports = (path, options) => ...` or `export default function(...) {...}`.
  2. If using TypeScript, build the resolver to JS first and point `resolver` at the compiled output.
  3. Print the actual export: `node -e "console.log(require('./my-resolver.js'))"` and ensure it is not null/undefined.

Example fix

// before — my-resolver.js (no exports)
const { defaultResolver } = require('jest-resolve/build/defaultResolver');
// forgot to export

// after
module.exports = (path, options) => defaultResolver(path, options);
Defensive patterns

Strategy: validation

Validate before calling

function assertResolverExportsSomething(resolverPath) {
  const mod = require(resolverPath);
  if (mod == null) {
    throw new Error(`Resolver ${resolverPath} exports nothing — add module.exports`);
  }
  return mod;
}

Type guard

function isNonNullableExport(m: unknown): boolean {
  return m != null;
}

Prevention

When it happens

Trigger: Setting `resolver: './my-resolver.js'` in jest config where that file has no `module.exports` / `export` statement, or where it only declares side effects. Also occurs if the file exports via a default ESM `export default` that the CJS `require()` wraps in `{ default: ... }` leaving the namespace itself non-null but the named export empty in some toolchains — though strictly this branch fires when the required value itself is null/undefined.

Common situations: Writing a resolver in ESM/TypeScript and forgetting to compile to CJS before pointing Jest at it; a resolver file that only does `module.exports = undefined` via a bad conditional; pointing at the wrong path (a `.d.ts` or a barrel that re-exports nothing).

Related errors


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/e9d50f9f803e3533.json. Report an issue: GitHub.