jestjs/jest · error · Error
Jest: '${loader}' is not a valid TypeScript configuration lo
Error message
Jest: '${loader}' is not a valid TypeScript configuration loader. What it means
registerTsLoader accepts only 'ts-node' or 'esbuild-register' as the loader name from the @jest-config-loader docblock pragma. Any other string value reaches the final throw in the if/else chain, telling the user the loader name is not recognized.
Source
Thrown at packages/jest-config/src/readConfigFileAndSetRootDir.ts:231
);
let instance: {unregister: () => void} | undefined;
return {
enabled: (bool: boolean) => {
if (bool) {
instance = tsLoader.register({
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
- Use only 'ts-node' or 'esbuild-register' as the @jest-config-loader value
- Remove the pragma to fall back to the default 'ts-node'
- Fix typos such as 'tsnode' -> 'ts-node'
Example fix
/** * @jest-config-loader @swc-node/register */ // becomes /** * @jest-config-loader esbuild-register */
Defensive patterns
Strategy: validation
Validate before calling
const VALID_LOADERS = new Set(['ts-node', 'esbuild-register']);
const loader = pragmas['jest-config-loader'];
if (typeof loader === 'string' && !VALID_LOADERS.has(loader)) {
throw new Error(`Unsupported loader: ${loader}`);
} Type guard
function isValidTsLoader(s: string): s is 'ts-node' | 'esbuild-register' {
return s === 'ts-node' || s === 'esbuild-register';
} Prevention
- Consult the jest-config docs for the loader whitelist
- Avoid rarely-supported loaders for config files
When it happens
Trigger: Setting `@jest-config-loader swc`, `@jest-config-loader @swc-node/register`, or a typo like `@jest-config-loader tsnode` in the config docblock.
Common situations: Typos in the loader name; assuming a loader Jest does not whitelist (e.g. swc, babel) is supported for config loading.
Related errors
- Jest: You can only define a single loader through docblocks,
- Jest: Failed to parse the TypeScript config file ${configPat
- Jest: '${loader}' is required for the TypeScript configurati
- 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/cab537ff26c05536.json.
Report an issue: GitHub.