{"id":"cab537ff26c05536","repo":"jestjs/jest","slug":"jest-loader-is-not-a-valid-typescript-config","errorCode":null,"errorMessage":"Jest: '${loader}' is not a valid TypeScript configuration loader.","messagePattern":"Jest: '(.+?)' is not a valid TypeScript configuration loader\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/readConfigFileAndSetRootDir.ts","lineNumber":231,"sourceCode":"      );\n\n      let instance: {unregister: () => void} | undefined;\n\n      return {\n        enabled: (bool: boolean) => {\n          if (bool) {\n            instance = tsLoader.register({\n              target: `node${process.version.slice(1)}`,\n              ...extraTSLoaderOptions,\n            });\n          } else {\n            instance?.unregister();\n          }\n        },\n      };\n    }\n\n    throw new Error(\n      `Jest: '${loader}' is not a valid TypeScript configuration loader.`,\n    );\n  } catch (error) {\n    if (\n      isError(error) &&\n      (error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND'\n    ) {\n      throw new Error(\n        `Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${error.message}`,\n        {cause: error},\n      );\n    }\n\n    throw error;\n  }\n}\n","sourceCodeStart":213,"sourceCodeEnd":248,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L213-L248","documentation":"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.","triggerScenarios":"Setting `@jest-config-loader swc`, `@jest-config-loader @swc-node/register`, or a typo like `@jest-config-loader tsnode` in the config docblock.","commonSituations":"Typos in the loader name; assuming a loader Jest does not whitelist (e.g. swc, babel) is supported for config loading.","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'"],"exampleFix":"/**\n * @jest-config-loader @swc-node/register\n */\n// becomes\n/**\n * @jest-config-loader esbuild-register\n */","handlingStrategy":"validation","validationCode":"const VALID_LOADERS = new Set(['ts-node', 'esbuild-register']);\nconst loader = pragmas['jest-config-loader'];\nif (typeof loader === 'string' && !VALID_LOADERS.has(loader)) {\n  throw new Error(`Unsupported loader: ${loader}`);\n}","typeGuard":"function isValidTsLoader(s: string): s is 'ts-node' | 'esbuild-register' {\n  return s === 'ts-node' || s === 'esbuild-register';\n}","tryCatchPattern":null,"preventionTips":["Consult the jest-config docs for the loader whitelist","Avoid rarely-supported loaders for config files"],"tags":["typescript","config","docblock","loader"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}