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
- Install the missing loader: `npm i -D ts-node` or `npm i -D esbuild-register`
- Ensure the loader is in devDependencies, not only a transitive dependency of another package
- 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
- Keep the docblock loader and devDependencies in sync
- Add a CI check that verifies the configured loader resolves
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
- Jest: Failed to parse the TypeScript config file ${configPat
- Jest: You can only define a single loader through docblocks,
- Jest: '${loader}' is not a valid TypeScript configuration lo
- jest.config.mts requires native TypeScript support. Ensure y
- ${moduleName} file must export a function at ${modulePath}
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/a3b224e1d4c1c2f2.json.
Report an issue: GitHub.