jestjs/jest · error · Error

Jest: '${loader}' is required for the TypeScript configurati

Error message

Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed
Error: ${error.message}

What it means

registerTsLoader tries to dynamically import the named loader module. If that import fails with ERR_MODULE_NOT_FOUND (the package is not installed), Jest rethrows with guidance naming the loader and instructing installation. This is distinct from error [66] which rejects unknown loader names entirely.

Source

Thrown at packages/jest-config/src/readConfigFileAndSetRootDir.ts:239

              target: `node${process.version.slice(1)}`,
              ...extraTSLoaderOptions,
            });
          } else {
            instance?.unregister();
          }
        },
      };
    }

    throw new Error(
      `Jest: '${loader}' is not a valid TypeScript configuration loader.`,
    );
  } catch (error) {
    if (
      isError(error) &&
      (error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND'
    ) {
      throw new Error(
        `Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed\nError: ${error.message}`,
        {cause: error},
      );
    }

    throw error;
  }
}

View on GitHub (pinned to f49721c78e)

Solutions

  1. Install the missing loader: `npm i -D ts-node` or `npm i -D esbuild-register`
  2. Ensure the loader is in devDependencies, not only a transitive dependency of another package
  3. Clear CI cache / reinstall node_modules if the package is listed but missing

Example fix

// before: docblock references esbuild-register, package not installed
/**
 * @jest-config-loader esbuild-register
 */
// after
npm install -D esbuild-register
Defensive patterns

Strategy: validation

Validate before calling

async function loaderIsInstalled(loader: string): Promise<boolean> {
  try { await import(loader); return true; } catch { return false; }
}
if (!(await loaderIsInstalled('ts-node'))) {
  throw new Error('ts-node is not installed');
}

Prevention

When it happens

Trigger: Configuring `@jest-config-loader esbuild-register` in the docblock without adding esbuild-register to devDependencies, or naming ts-node without installing it.

Common situations: New teammate cloning a repo whose docblock references a loader not in package.json; switching loaders without updating installs; CI caching that skips optional deps.

Related errors


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