{"record":{"id":"8835300b461a195c","repo":"jestjs/jest","slug":"custom-export-conditions-specified-but-they-are-no-883530","errorCode":null,"errorMessage":"Custom export conditions specified but they are not an array of strings","messagePattern":"Custom export conditions specified but they are not an array of strings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-environment-node/src/index.ts","lineNumber":211,"sourceCode":"      // @ts-expect-error - it's readonly - but we have checked above that it's not there\n      globalSymbol.asyncDispose = globalSymbol.for('nodejs.asyncDispose');\n      // @ts-expect-error - it's readonly - but we have checked above that it's not there\n      globalSymbol.dispose = globalSymbol.for('nodejs.dispose');\n    }\n\n    // Node's error-message stack size is limited at 10, but it's pretty useful\n    // to see more than that when a test fails.\n    global.Error.stackTraceLimit = 100;\n\n    if ('customExportConditions' in projectConfig.testEnvironmentOptions) {\n      const {customExportConditions} = projectConfig.testEnvironmentOptions;\n      if (\n        Array.isArray(customExportConditions) &&\n        customExportConditions.every(isString)\n      ) {\n        this._configuredExportConditions = customExportConditions;\n      } else {\n        throw new Error(\n          'Custom export conditions specified but they are not an array of strings',\n        );\n      }\n    }\n\n    this.moduleMocker = new ModuleMocker(global);\n\n    this.fakeTimers = new LegacyFakeTimers({\n      config: projectConfig,\n      global,\n      moduleMocker: this.moduleMocker,\n      timerConfig: {\n        idToRef: timerIdToRef,\n        refToId: timerRefToId,\n      },\n    });\n\n    this.fakeTimersModern = new ModernFakeTimers({","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-environment-node/src/index.ts#L193-L229","documentation":"Thrown by the Node environment constructor when `testEnvironmentOptions.customExportConditions` is present but is not an array of strings. Same validation logic as the jsdom environment — `Array.isArray(...) && every(isString)`. The default for node is `['node', 'node-addons']`.","triggerScenarios":"Setting `testEnvironmentOptions: { customExportConditions: 'node' }` (string) or `{ customExportConditions: ['node', 42] }` (mixed types) in jest.config.js when using `testEnvironment: 'node'`.","commonSituations":"Same as error 92 but in node environment context. Typing the value as a string or object. Configuring conditions for dual-package exports (ESM/CJS) with the wrong type.","solutions":["Set `customExportConditions` to an array of strings: `['node', 'node-addons']`.","Remove the option if the default conditions are acceptable.","Validate the type with `Array.isArray()` before committing config changes."],"exampleFix":"// before\nmodule.exports = {\n  testEnvironment: 'node',\n  testEnvironmentOptions: { customExportConditions: 'node' },\n};\n\n// after\nmodule.exports = {\n  testEnvironment: 'node',\n  testEnvironmentOptions: { customExportConditions: ['node'] },\n};","handlingStrategy":"type-guard","validationCode":"// Same validation for node environment\nfunction validateNodeExportConditions(opts) {\n  if ('customExportConditions' in opts) {\n    const c = opts.customExportConditions;\n    if (!Array.isArray(c) || !c.every(v => typeof v === 'string')) {\n      throw new TypeError('customExportConditions must be an array of strings');\n    }\n  }\n}","typeGuard":"function isStringArray(value: unknown): value is string[] {\n  return Array.isArray(value) && value.every(v => typeof v === 'string');\n}","tryCatchPattern":null,"preventionTips":["Always type customExportConditions as string[].","Review testEnvironmentOptions in config reviews.","Document the expected type in a config schema or comment."],"tags":["jest-environment-node","configuration","export-conditions","validation"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}