{"id":"74d328959b9b8379","repo":"jestjs/jest","slug":"configuration-in-packagejson-is-not-valid-jest","errorCode":null,"errorMessage":"Configuration in ${packageJson} is not valid. Jest expects the string configuration to point to a file, but ${absolutePath} is not. Please check your Jest configuration in ${packageJson}.","messagePattern":"Configuration in (.+?) is not valid\\. Jest expects the string configuration to point to a file, but (.+?) is not\\. Please check your Jest configuration in (.+?)\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/jest-config/src/resolveConfigPath.ts","lineNumber":89,"sourceCode":"  skipMultipleConfigError: boolean,\n): string => {\n  const configFiles = JEST_CONFIG_EXT_ORDER.map(ext =>\n    path.resolve(pathToResolve, getConfigFilename(ext)),\n  ).filter(isFile);\n\n  const packageJson = findPackageJson(pathToResolve);\n\n  if (packageJson) {\n    const jestKey = getPackageJsonJestKey(packageJson);\n\n    if (jestKey) {\n      if (typeof jestKey === 'string') {\n        const absolutePath = path.isAbsolute(jestKey)\n          ? jestKey\n          : path.resolve(pathToResolve, jestKey);\n\n        if (!isFile(absolutePath)) {\n          throw new ValidationError(\n            `${BULLET}Validation Error`,\n            `  Configuration in ${chalk.bold(packageJson)} is not valid. ` +\n              `Jest expects the string configuration to point to a file, but ${absolutePath} is not. ` +\n              `Please check your Jest configuration in ${chalk.bold(\n                packageJson,\n              )}.`,\n            DOCUMENTATION_NOTE,\n          );\n        }\n\n        configFiles.push(absolutePath);\n      } else {\n        configFiles.push(packageJson);\n      }\n    }\n  }\n\n  if (!skipMultipleConfigError && configFiles.length > 1) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-config/src/resolveConfigPath.ts#L71-L107","documentation":"When the `jest` key in package.json is a string, Jest treats it as a path to a config file (a common shorthand). resolveConfigPathByTraversing resolves that string to an absolute path and checks it is a file; if not, it throws a ValidationError. This is distinct from the jest key being an inline object, which is always accepted.","triggerScenarios":"Setting `\"jest\": \"./jest.config.js\"` in package.json when that file does not exist, or pointing it at a directory.","commonSituations":"Renaming or deleting the referenced config file without updating package.json; wrong relative path; pointing at a file outside the project root.","solutions":["Create the file the jest string points to, or correct the path","Change the jest key to an inline object if you want config inside package.json","Point the string at an existing absolute or correct relative path"],"exampleFix":"// before (package.json)\n{ \"jest\": \"./config/jest.js\" }\n// after\n{ \"jest\": \"./jest.config.js\" }","handlingStrategy":"validation","validationCode":"import * as fs from 'node:fs';\nconst pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));\nif (typeof pkg.jest === 'string' && !fs.existsSync(pkg.jest)) {\n  throw new Error(`jest config file not found: ${pkg.jest}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the package.json jest string and the referenced file in sync","Prefer an inline object for small configs to avoid path drift"],"tags":["config","package-json","validation"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}