{"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/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-environment-node/src/index.ts#L193-L229","documentation":"The Node environment performs the same customExportConditions validation as the JSDOM base (default `['node','node-addons']`). It throws at index.ts:211 when the value is present but not an Array<string>, preventing a malformed resolver config from silently resolving the wrong package entry.","triggerScenarios":"Setting `testEnvironmentOptions.customExportConditions` to a non-array or to an array containing non-strings while using `jest-environment-node`.","commonSituations":"Sharing a config across environments where one path used a string; tooling that injects a single condition string; misreading the docs and passing `'node-addons'` instead of `['node-addons']`.","solutions":["Use an array of strings, e.g. `customExportConditions: ['node', 'node-addons']`.","Drop the option to keep the environment defaults.","Validate the config shape with a startup check that `Array.isArray` and `every(isString)`."],"exampleFix":"// before\ntestEnvironmentOptions: { customExportConditions: 'node' }\n\n// after\ntestEnvironmentOptions: { customExportConditions: ['node'] }","handlingStrategy":"validation","validationCode":"const opts = config.testEnvironmentOptions?.customExportConditions;\nif (opts != null && (!Array.isArray(opts) || opts.every === undefined || !opts.every((x: unknown) => typeof x === 'string'))) {\n  throw new TypeError('customExportConditions must be string[]');\n}","typeGuard":"const isStringArray = (v: unknown): v is string[] => Array.isArray(v) && v.every(x => typeof x === 'string');","tryCatchPattern":null,"preventionTips":["Use the default unless you explicitly need a custom condition.","Lint config files for non-array customExportConditions."],"tags":["jest-environment","node","config","exports"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}