{"id":"51ac210d5b652c7f","repo":"jestjs/jest","slug":"invalid-transformer-module-slash-transform","errorCode":null,"errorMessage":"● Invalid transformer module:\n  \"${slash(transformPath)}\" specified in the \"transform\" object of Jest configuration\n  must export a `process` or `processAsync` or `createTransformer` function.\n\n  Code Transformation Documentation:\n  https://jestjs.io/docs/code-transformation\n","messagePattern":"● Invalid transformer module:\n  \"(.+?)\" specified in the \"transform\" object of Jest configuration\n  must export a `process` or `processAsync` or `createTransformer` function\\.\n\n  Code Transformation Documentation:\n  https://jestjs\\.io/docs/code-transformation\n","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-transform/src/ScriptTransformer.ts","lineNumber":284,"sourceCode":"\n  private _getTransformPath(filename: string) {\n    const transformInfo = this._getTransformPatternAndPath(filename);\n    if (!Array.isArray(transformInfo)) {\n      return undefined;\n    }\n\n    return transformInfo[1];\n  }\n\n  async loadTransformers(): Promise<void> {\n    await Promise.all(\n      this._config.transform.map(\n        async ([transformPattern, transformPath, transformerConfig], i) => {\n          let transformer: Transformer | TransformerFactory<Transformer> =\n            await requireOrImportModule(transformPath);\n\n          if (transformer == null) {\n            throw new Error(makeInvalidTransformerError(transformPath));\n          }\n          if (isTransformerFactory(transformer)) {\n            transformer =\n              await transformer.createTransformer(transformerConfig);\n          }\n          if (\n            typeof transformer.process !== 'function' &&\n            typeof transformer.processAsync !== 'function'\n          ) {\n            throw new TypeError(makeInvalidTransformerError(transformPath));\n          }\n          const res = {transformer, transformerConfig};\n          const transformCacheKey = this._buildTransformCacheKey(\n            this._cache.transformRegExp?.[i]?.[0].source ??\n              new RegExp(transformPattern).source,\n            transformPath,\n          );\n          this._transformCache.set(transformCacheKey, res);","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-transform/src/ScriptTransformer.ts#L266-L302","documentation":"Thrown by `loadTransformers` (ScriptTransformer.ts:283-285) via `makeInvalidTransformerError` when a configured transformer module loads to `null`/`undefined`. The transform config entry resolved and required successfully, but the module exports nothing (no default, no named `process`/`processAsync`/`createTransformer`).","triggerScenarios":"A `transform` config entry points at a module whose `module.exports` / `export default` is null or absent - e.g. a module that only has side effects, a CommonJS module that forgot to assign `module.exports`, or an ESM module with only named exports when Jest needs a default.","commonSituations":"Mistyped transformer path resolving to an incidental index.js that exports nothing; transformer written as ESM with named exports but no default/factory; circular-import edge case causing the module object to be undefined at require time; transformer package that was tree-shaken or whose main field points at the wrong file.","solutions":["Open the resolved transformer module and confirm it exports one of: `process`, `processAsync`, or `createTransformer` (or a default object containing them).","For CommonJS: ensure `module.exports = { process(...) {...} }` (or `module.exports = { createTransformer }`).","Print the resolved path with `require.resolve('your-transformer')` and verify it points where you expect.","Update the `transform` entry's second tuple element to the correct file."],"exampleFix":"// before: my-transformer.js (exports nothing)\nconst { compile } = require('./compiler');\nfunction process(src, filename) { return { code: compile(src) }; }\n// after\nconst { compile } = require('./compiler');\nmodule.exports = {\n  process(src, filename) { return { code: compile(src) }; },\n};","handlingStrategy":"type-guard","validationCode":"const mod = require(transformPath);\nif (mod == null) throw new Error('transformer module exports nothing');","typeGuard":"const hasTransformerExport = (m: any): boolean =>\n  m != null && (typeof m.process === 'function' || typeof m.processAsync === 'function' || typeof m.createTransformer === 'function');","tryCatchPattern":null,"preventionTips":["Always assign `module.exports = { process() {...} }` (or default-export an object/factory).","After writing the transformer, `console.log(require.resolve('./my-transformer'))` and inspect the export.","Add a smoke test that requires the transformer and asserts `typeof mod.process === 'function'`."],"tags":["jest-transform","config","transformer","user-error"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}