{"record":{"id":"a3b224e1d4c1c2f2","repo":"jestjs/jest","slug":"jest-loader-is-required-for-the-typescript-c","errorCode":null,"errorMessage":"Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed\nError: ${error.message}","messagePattern":"Jest: '(.+?)' is required for the TypeScript configuration files\\. Make sure it is installed\nError: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/readConfigFileAndSetRootDir.ts","lineNumber":240,"sourceCode":"              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":222,"sourceCodeEnd":249,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L222-L249","documentation":"Thrown by registerTsLoader when the dynamic import() of the chosen loader package fails with ERR_MODULE_NOT_FOUND. The loader is named in the @jest-config-loader pragma (or defaults to 'ts-node'), but the package is not resolvable from the project. The original error is attached as {cause}.","triggerScenarios":"Declaring @jest-config-loader ts-node without installing ts-node; running in a monorepo where the loader is hoisted to a workspace root Jest cannot resolve from; using esbuild-register without adding it to package.json.","commonSituations":"Fresh clones where devDependencies weren't installed (yarn install --production); monorepo hoisting differences; CI caches that dropped optional deps.","solutions":["Install the named loader: npm install -D ts-node (or esbuild-register)","If in a monorepo, ensure the loader is resolvable from the package running Jest (add to that workspace's deps or fix hoisting)","Remove the @jest-config-loader pragma and rely on native Node TS support if you're on Node 22.18+/23.6+","Run node -e \"require.resolve('ts-node')\" from the project to confirm resolution"],"exampleFix":"// before: pragma set, ts-node missing\n/**\n * @jest-config-loader ts-node\n */\n\n// after: install it\n// npm install -D ts-node","handlingStrategy":"validation","validationCode":"import * as fs from 'node:fs';\nfunction assertLoaderInstalled(loader: 'ts-node' | 'esbuild-register'): void {\n  try {\n    require.resolve(loader);\n  } catch {\n    throw new Error(`${loader} is not installed. Run: npm install -D ${loader}`);\n  }\n}","typeGuard":"async function isLoaderInstalled(loader: string): Promise<boolean> {\n  try { await import(loader); return true; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Add the chosen loader to devDependencies and commit package.json","Run npm ci / yarn install --frozen-lockfile in CI to ensure all deps present","In monorepos, verify resolution from the workspace running Jest"],"tags":["typescript","config","loader","missing-dependency","docblock"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}