mui/material-ui · error · Error
Version ${majorVersion} does not have version defined for th
Error message
Version ${majorVersion} does not have version defined for the ${packageName} What it means
Thrown when additionalVersionsMappings has an entry for the requested React major version but that entry is missing a version for one of the names in devDependenciesPackageNames. In the current source only React 17 is mapped and it covers `@testing-library/react`, so in practice this fires only when a maintainer adds a new major version (e.g. 18, 19) with an incomplete mapping, or extends devDependenciesPackageNames without backfilling every major version in additionalVersionsMappings. It is a config-completeness guard, not a user-input error.
Source
Thrown at scripts/useReactVersion.mjs:88
throw new Error(`Could not find '${version}' in "${versions}"`);
}
} else {
packageVersion = tagMapping.replace(`${version}: `, '');
}
packageJson.resolutions[reactPackageName] = packageVersion;
}),
);
// At this moment all dist tags reference React 18 version, so we don't need
// to update these dependencies unless an older version is used, or when the
// next/experimental dist tag reference to a future version of React
// packageJson.devDependencies['@testing-library/react'] = 'alpha';
if (majorVersion && additionalVersionsMappings[majorVersion]) {
devDependenciesPackageNames.forEach((packageName) => {
if (!additionalVersionsMappings[majorVersion][packageName]) {
throw new Error(
`Version ${majorVersion} does not have version defined for the ${packageName}`,
);
}
packageJson.resolutions[packageName] = additionalVersionsMappings[majorVersion][packageName];
});
}
// add newline for clean diff
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}${os.EOL}`);
console.log('Installing dependencies...');
const pnpmInstall = childProcess.spawn('pnpm', ['install', '--no-frozen-lockfile'], {
shell: true,
stdio: ['inherit', 'inherit', 'inherit'],
});
pnpmInstall.on('exit', (exitCode) => {
if (exitCode !== 0) {
throw new Error('Failed to install dependencies');View on GitHub (pinned to bdc96df2cb)
Solutions
- Open scripts/useReactVersion.mjs and add the missing entry under additionalVersionsMappings[majorVersion] for the named package.
- If the dev-dep should not be pinned per React version, remove it from devDependenciesPackageNames instead of adding a mapping.
- After editing, re-run `node scripts/useReactVersion.mjs <version>` to confirm the matrix resolves cleanly.
Example fix
// before
const additionalVersionsMappings = {
17: { '@testing-library/react': '^12.1.0' },
};
// after
const additionalVersionsMappings = {
17: { '@testing-library/react': '^12.1.0' },
18: { '@testing-library/react': '^13.4.0' },
}; Defensive patterns
Strategy: validation
Validate before calling
// Detect a partial additionalVersionsMappings entry before running the
// script. Add this as a unit test in the repo so refactors fail fast.
const devDependenciesPackageNames = ['@testing-library/react'];
const additionalVersionsMappings: Record<number, Record<string, string>> = {
17: { '@testing-library/react': '^12.1.0' },
};
function assertMappingsComplete() {
for (const [major, mapping] of Object.entries(additionalVersionsMappings)) {
for (const dep of devDependenciesPackageNames) {
if (typeof mapping[dep] !== 'string') {
throw new Error(
`additionalVersionsMappings[${major}] is missing entry for "${dep}".`,
);
}
}
}
} Type guard
// Narrows a major-version mapping to one that covers every dev dep.
function isCompleteMapping(
mapping: unknown,
required: readonly string[],
): mapping is Record<string, string> {
if (typeof mapping !== 'object' || mapping === null) return false;
const m = mapping as Record<string, unknown>;
return required.every((name) => typeof m[name] === 'string' && m[name].length > 0);
} Try / catch
// When extending the script with a new React major, wrap the run so the
// missing-mapping error points at the file/line that needs editing.
try {
await main(version);
} catch (err) {
if (err instanceof Error && /does not have version defined for the/.test(err.message)) {
throw new Error(
`${err.message} Update additionalVersionsMappings in scripts/useReactVersion.mjs, ` +
`or remove the package from devDependenciesPackageNames.`,
);
}
throw err;
} Prevention
- Treat additionalVersionsMappings and devDependenciesPackageNames as a paired schema — add a unit test that asserts completeness.
- When adding a new React major, copy an existing entry and edit every value, do not start from an empty object.
- When adding a new dev-dep name, backfill it under every existing major key in the same commit.
- Run the script locally with the new major version before pushing the CI change.
When it happens
Trigger: A maintainer adds `18: { }` (or a partial object) to additionalVersionsMappings and runs the script with a React 18 version; or adds a new entry like `@testing-library/react-hooks` to devDependenciesPackageNames without adding it under key 17. The forEach hits the missing combination and throws.
Common situations: Refactoring the dev-dep pin list; introducing support for a new React major in a hurry; copy-pasting a partial mapping from a PR; renaming a package in devDependenciesPackageNames but not in the mappings.
Related errors
- No TabContext provided
- No TabContext provided
- MUI: MenuListContext is missing. MenuItems must be placed wi
- MUI: RovingTabIndexContext is missing. Roving tab index item
- expected version: string but got '${version}'
AI-assisted analysis of mui/material-ui@bdc96df2cb (2026-08-12).
Data as JSON: /api/errors/9ac1c3c3951a70a2.
Report an issue: GitHub.