{"record":{"id":"55bd4e2b274e90c3","repo":"avajs/ava","slug":"conflicting-configuration-in-fileforerrormessage","errorCode":null,"errorMessage":"Conflicting configuration in ${fileForErrorMessage} and ${conflicting.map(({fileForErrorMessage}) => fileForErrorMessage).join(' & ')}","messagePattern":"Conflicting configuration in (.+?) and (.+?)\\) => fileForErrorMessage\\)\\.join\\(' & '\\)\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/load-config.js","lineNumber":128,"sourceCode":"\t\tdo {\n\t\t\tconst [jsonFile, ...results] = await Promise.all([ // eslint-disable-line no-await-in-loop\n\t\t\t\tcheckJsonFile(searchDir),\n\t\t\t\tloadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.js')}),\n\t\t\t\tloadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.mjs')}),\n\t\t\t]);\n\n\t\t\tif (jsonFile !== null) {\n\t\t\t\tunsupportedFiles.push(jsonFile);\n\t\t\t}\n\n\t\t\t[{config: fileConf, fileForErrorMessage, configFile} = {config: NO_SUCH_FILE, fileForErrorMessage: undefined}, ...conflicting] = results.filter(result => result !== null);\n\n\t\t\tsearchDir = path.dirname(searchDir);\n\t\t} while (fileConf === NO_SUCH_FILE && searchDir !== stopAt);\n\t}\n\n\tif (conflicting.length > 0) {\n\t\tthrow new Error(`Conflicting configuration in ${fileForErrorMessage} and ${conflicting.map(({fileForErrorMessage}) => fileForErrorMessage).join(' & ')}`);\n\t}\n\n\tif (fileConf !== NO_SUCH_FILE) {\n\t\tif (allowConflictWithPackageJson) {\n\t\t\tpackageConf = {};\n\t\t} else if (Object.keys(packageConf).length > 0) {\n\t\t\tthrow new Error(`Conflicting configuration in ${fileForErrorMessage} and package.json`);\n\t\t}\n\n\t\tif (!isPlainObject(fileConf) && typeof fileConf !== 'function') {\n\t\t\tthrow new TypeError(`${fileForErrorMessage} must export a plain object or factory function`);\n\t\t}\n\n\t\tif (typeof fileConf === 'function') {\n\t\t\tfileConf = await fileConf({projectDir});\n\n\t\t\tif (!isPlainObject(fileConf)) {\n\t\t\t\tthrow new TypeError(`Factory method exported by ${fileForErrorMessage} must return a plain object`);","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/load-config.js#L110-L146","documentation":"When AVA searches upward from the project directory it may find multiple config files (ava.config.js, .avarc, etc.). If more than one config file is found in different searched directories, loadConfig throws to avoid ambiguous, conflicting configuration.","triggerScenarios":"Having both ava.config.js in the repo root and an ava.config.mjs/.avarc in a subdirectory from which AVA resolves config, so the upward search discovers several files that each define configuration.","commonSituations":"Leftover config file from a previous AVA version or tool rename; monorepo where a nested package kept its own ava config; duplicated config after copy-pasting a project.","solutions":["Delete or rename the older/extra config file, keeping exactly one.","Consolidate all AVA options into the single top-level config file.","Search the repo for ava.config.*, .avarc, and package.json 'ava' keys and remove strays.","Run AVA from the directory whose config you intend to use."],"exampleFix":"// before: repo root has ava.config.js AND packages/app/ava.config.mjs\n// after: delete packages/app/ava.config.mjs, keep ava.config.js at root\n$ git rm packages/app/ava.config.mjs","handlingStrategy":"validation","validationCode":"import {globbySync} from 'globby';\nconst found = globbySync(['ava.config.{js,mjs,cjs}', '.avarc', 'ava.config.json'], {gitignore: false});\nif (found.length > 1) throw new Error(`Multiple AVA configs found: ${found.join(', ')}`);","typeGuard":"const hasSingleConfig = files => files.length === 1;","tryCatchPattern":"try {\n  await run();\n} catch (err) {\n  if (err.message.startsWith('Conflicting configuration in')) {\n    console.error('Keep exactly one AVA config file in the project');\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Grep the repo for ava.config.* and .avarc before upgrading AVA.","Keep one config at the project root; use project/workspaces config intentionally.","Remove stale configs from copied or renamed packages.","Document the single-config convention in the repo README."],"tags":["configuration","conflict","multiple-config-files"],"backgroundTag":"conflicting-config-files","analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}