mui/material-ui · error · Error
Could not find '${version}' in "${versions}"
Error message
Could not find '${version}' in "${versions}" What it means
Thrown when the requested `version` is treated as a dist-tag name but `npm dist-tag ls <pkg>` produced no line beginning with `${version}: `, AND the version string did not look like a concrete semver (it did not start with `^`, `~`, or a digit, so majorVersion stayed null). The check runs inside the reactPackageNames.map loop, so it fires on the first React package whose tag list lacks the entry — typically `react` itself.
Source
Thrown at scripts/useReactVersion.mjs:70
const tagMapping = versions.split('\n').find((mapping) => {
return mapping.startsWith(`${version}: `);
});
let packageVersion = null;
if (tagMapping === undefined) {
// Some specific version is being requested
if (majorVersion) {
packageVersion = version;
if (reactPackageName === 'scheduler') {
// get the scheduler version from the react-dom's dependencies entry
const { stdout: reactDOMDependenciesString } = await exec(
`npm view --json react-dom@${version} dependencies`,
);
packageVersion = JSON.parse(reactDOMDependenciesString).scheduler;
}
} else {
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(View on GitHub (pinned to bdc96df2cb)
Solutions
- List the real tags with `npm dist-tag ls react` and pass one of those names.
- If you want a concrete release instead of a tag, pass a real version (`18.2.0`) or range (`^18`) — those go through the majorVersion branch and skip this throw.
- Check registry connectivity and config (`npm config get registry`, `npm ping`) if the tag list comes back empty.
Example fix
// before $ node scripts/useReactVersion.mjs nex # Error: Could not find 'nex' in "" // after $ node scripts/useReactVersion.mjs next # (script proceeds to rewrite resolutions and run pnpm install)
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: confirm the requested tag exists on npm for every React
// package the script will iterate, so the dist-tag ls loop never throws.
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
const execAsync = promisify(exec);
const reactPackages = ['react', 'react-dom', 'react-is', 'scheduler'];
async function assertTagExists(tag: string) {
if (/^[~^]/.test(tag) || /^\d/.test(tag)) return; // concrete version/range, not a tag
for (const pkg of reactPackages) {
const { stdout } = await execAsync(`npm dist-tag ls ${pkg}`);
if (!stdout.split('\n').some((line) => line.startsWith(`${tag}: `))) {
throw new Error(`dist-tag "${tag}" not found for ${pkg}. Available:\n${stdout}`);
}
}
} Type guard
// Narrows a candidate to a known dist-tag name given an npm tag listing.
function isKnownDistTag(
tag: string,
listing: string,
): tag is string {
return listing.split('\n').some((line) => line.startsWith(`${tag}: `));
} Try / catch
// Distinguish a tag-not-found error from other failures so callers can
// suggest the list of available tags.
try {
await main(version);
} catch (err) {
if (err instanceof Error && /Could not find/.test(err.message)) {
const { stdout } = await execAsync('npm dist-tag ls react');
throw new Error(`Unknown tag "${version}". Available react dist-tags:\n${stdout}`);
}
throw err;
} Prevention
- Before introducing a new tag value into CI, run `npm dist-tag ls react` and copy the exact name.
- Prefer concrete versions (`18.2.0`) over tags when reproducibility matters — they bypass the dist-tag lookup entirely.
- Pin the registry with `npm config set registry` in mirrored environments so dist-tags are not silently empty.
- Add a wrapper that, on this specific error, prints the available tags for `react` so the next attempt is correct.
When it happens
Trigger: Passing a tag name that does not exist on the npm registry for the React packages, e.g. `node scripts/useReactVersion.mjs rc` when there is no `rc` dist-tag. Also fires for arbitrary non-version strings (`latest2`, `foobar`) because they neither match a dist-tag nor parse as a semver.
Common situations: Typo in the tag name (`next` vs `nex`); the React maintainers renamed or removed a dist-tag; querying against a private registry mirror that does not propagate dist-tags; using a tag name that only some sub-packages publish.
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
- Workspace ${name} not found
AI-assisted analysis of mui/material-ui@bdc96df2cb (2026-08-12).
Data as JSON: /api/errors/17aba74be7fe5132.
Report an issue: GitHub.